Reverse Geocoding code

• To: mathgroup at smc.vnet.net
• Subject: [mg100374] Reverse Geocoding code
• From: "Coleman, Mark" <Mark.Coleman at LibertyMutual.com>
• Date: Tue, 2 Jun 2009 06:43:19 -0400 (EDT)

```Greetings,

Periodically I use Mathematica to help with geospatial analysis. Recently,
lat-long coordinates (within a reasonable degree of specificity). Here
is some Mathematica code to do this:

reverseGeoCode[{lat_,long_},outputType_]:=

>"key
="<>apiKey;
geoRes=ToExpression["{"<>Import[finalURL]<>"}"];
geoRes

];

This essentially involves converting the lat-long code to a string, then
composing the appropriate URL to invoke the Google web service. This is
trivial in Mathematica (I'm running v7) and, in my experience, a great way to
highlight the power of Mathematica to my business colleages (when I'm not
rotating a 3-d graphic for them!)

Please note that in order to run this code, you need to have a
Google-issued API Key (I've removed my key from the above code -- just
replace it with yours). The keys are free and give you access to
Google's online web services. I've found that performance is generally
pretty good, thought Google does place a limit on how many times you can
call this service during a 24 hour period (the number is around 5000 per
IP Address). So if you have a large number of addresses to reverse
geocode, this may not be the most efficient way to do so. Also, this
works quite well for U.S. lat-long coordinates. I have not tested it for
other countries.

As an example:

In[72]:= computeLatLong[{"100 Trade Center Drive", "Champaign", "IL"
,"61820-7237"}, "csv"]

Out[72]= {200, 8, 40.0971, -88.2456}

Cheers!

Mark S. Coleman
Claims Research & Development

Personal Market Claims
Mark.Coleman at libertymutual.com
Boston: (617) 654-4572  SDN: 8-654-4572
Portsmouth: (603) 245-5003
NOTICE: The information contained in this electronic mail transmission
is intended by Liberty Mutual for the use of the named individual or
entity to which it is directed and may contain information that is
privileged or otherwise confidential. If you have received this