Search code examples
geolocationgeonames

How do I use geonames data to determine latitude and longitude of a zip code?


I was referred to GeoNames in order to store their locations in my local database. After looking at their data, and data formats, I am not sure how to figure out a latitude/longitude being provided zip code?

For example: Input: 60614 output: 40.1234, -87.98766

I dont know how to use their data basically?

I would like to store the US.zip data into my local database, and be able to query it, by '60614' and it return lat/long. How could I do this?


Solution

  • http://api.geonames.org/findNearbyPostalCodes?lat=47&lng=9&username=demo will return some xml to you... now you have to parse it. replace the lat=47 and the lng=9 with your desired latitude/longitude coordinates.

    this is pretty much from thier API documentation,btw

    how to parse the xml depends on what language you are using.