I am writing a research proposal for a project on voter turnout as related to proximity to mass transit. The first part of my project would require geocoding hundreds of thousands of addresses, but I'd rather not have my laptop running ArcGIS for days on end to do it. My school's supercomputer does not have GIS software but it does have Mathematica Version 8. Is there a way to geocode addresses in Mathematica? I've found several workaround solutions online, but nothing that I think would get the approval of the campus IT office.

  • $\begingroup$ That data should exists already, try contacting local government or buy it from some map company like google maps $\endgroup$ – ssch Feb 4 '13 at 21:51
  • 4
    $\begingroup$ You can use Mathematica to implement any Web-based method described on the GIS site. For instance, about 20 months ago I searched that site for solutions and implemented two of them in MMA--Google Maps and Yahoo Maps. These are contractually limited to a few thousand per day (which was good enough for me), but there are others with fewer limitations. The GIS community can also provide advice on commercial solutions. $\endgroup$ – whuber Feb 4 '13 at 22:44

This is a very simple geocoder that I wrote some time ago.

cleanString[string_] := Module[{l1,l2},
    l1 = Characters@"ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðñòóôõöùúûüýÿ";
    l2 = Characters@"SZszYAAAAAACEEEEIIIIDNOOOOOUUUUYaaaaaaceeeeiiiidnooooouuuuyy";
    StringReplace[string, Thread[l1 -> l2]~Join~{" " -> "%20", "," -> "%2C"}]

(* Works with Google map API version 3 *)
geoCoder[address_] := Module[{getGeo, geo, cod = 0, i = 0, link}, 
    link = cleanString@address;
    link = "https://maps.googleapis.com/maps/api/geocode/json?address=" <>link;
    Import[link, {"JSON", "Data", "results", 1, "geometry", "location"}]];   

Testing it with:

geoCoder["Av Paulista, 510, Sao Paulo, Brasil"]

you get the right coordinates:


Here is the Google Documentation about request limits. The free one has a limit of 2.500 requests per day.

  • 1
    $\begingroup$ You can try other geocoding API: 7 Free Geocoding APIs: Google, Bing, Yahoo and MapQuest, APIs are very similar $\endgroup$ – Tuku Feb 5 '13 at 15:51
  • $\begingroup$ I implemented your geocoder into my init.m file and it worked for awhile but now I get the following error message: " Import::noelem: The Import element "1" is not present when importing as JSON. " What has changed? $\endgroup$ – EdN Oct 21 '18 at 23:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.