MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Re: Geocoding using Mathematica

  • To: mathgroup at
  • Subject: [mg83863] RE: [mg83778] Re: Geocoding using Mathematica
  • From: "Hobbs, Sylvia (DPH)" <Sylvia.Hobbs at>
  • Date: Mon, 3 Dec 2007 05:41:02 -0500 (EST)
  • References: <fim82v$qus$> <>


Yes, that's one way to skin a cat, but not my idea of information on 
demand. Why parse using pattern matching from outside XML outputs 
(especially if you have to geocode, say, a million data points) when a 
possible Mathematica upgrade could incorporate a true geocoding add-in 
tool as deployed in the statistical functioning architecture of several 
Business Intelligence software products? (...which will remained unnamed 
- pace Wolfram Forum moderator) Mapping software companies are forming 
targeted open source alliances with specialized software companies 
allowing dynamic links between data subject matter analysis and 
real-time base location area map changes. This seems like such a timely 
ad-hoc integration that could save future generations from wasting the 
best years of their life PARSING DATA!!!

Sylvia Hobbs


From: mathgroup-adm at on behalf of mcmcclur at
Sent: Fri 11/30/2007 5:22 AM
To: mathgroup at
Subject: [mg83863] [mg83778] Re: Geocoding using Mathematica

On Nov 29, 6:33 am, "Coleman, Mark" <Mark.Cole... at>
> There are a number of freely available web-based geocoding
> services.  Would it possible to invoke them via Mathematica?

Sure, Mathematica has built in features that make this easy.

A good web-based geolocator will allow you to access its
data via a URL with a query string and give you the option
to retrieve it's output as XML.  Thus, you can Import from a
URL to symbolic XML, which Mathematica can easily parse
using pattern matching., for example, returns three results for "The
White House" in Washington, DC.

-- In --
result = Import[
#[[3, 1]] & /@ Cases[result,
  XMLElement["name", __], Infinity]

-- Out --
{The White House, The White House Visitor Center,
 The Hay Adams across from the White House}

It appears that the first of these is the actual Presidential
residence.  Here's the latitude and longitude.

-- In --
{latString, lngString} = First /@ Map[#[[3, 1]] &,
    {Cases[result, XMLElement["lat", __], Infinity],
    Cases[result, XMLElement["lng", __], Infinity]},

-- Out --
{38.8976118, -77.0363658}

These results are strings, so be sure to use ToExpression,
if you want to do any numeric work.  On the other hand, it
might be nice to leave them as strings.  For example, we can
pass them straight back to geonames to get the elevation.

-- In --
Import[""; <>
  latString <> "&lng=" <> lngString]

-- Out --

The result is a simple string indicating the elevation in

Have fun,

  • Prev by Date: Re: how draw box with open front
  • Next by Date: Re: The integrand has evaluated to non-numerical values for all
  • Previous by thread: Re: Slider[] and Dynamic[] implementation details
  • Next by thread: widget with a graphic