It is currently March 28th, 2024, 3:02 pm

free open geocoding apis

Tips and Tricks from the Rainmeter Community
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

free open geocoding apis

Post by moshi »

sometimes you need the longitude and latitude of a place, be it for using it in a weather skin or searching nearby places.
mostly the Yahoo! api is used for that, but this service might be stopped any day. so as i played with a few apis while working on Evi, i thought i write these down. might be useful one day.
this list only has world-wide services that do not require an api-key and that do not require the query to be split up.

Yahoo!

Code: Select all

http://where.yahooapis.com/geocode?location=Downing Street 10, London&flags=XRT
[/strike]

Google

Code: Select all

http://maps.googleapis.com/maps/api/geocode/xml?address=Downing Street 10, London&sensor=false
MapQuest

Code: Select all

http://open.mapquestapi.com/geocoding/v1/address?location=Downing Street 10, London
Nominatim (OpenStreetMap)

Code: Select all

http://nominatim.openstreetmap.org/search?q=Downing Street 10, London&format=xml&polygon=0&addressdetails=1&accept-language=en_us
Yandex

Code: Select all

http://geocode-maps.yandex.ru/1.x/?geocode=Downing Street 10, London&lang=en-US&format=xml&results=1
Data Science Toolkit

Code: Select all

http://www.datasciencetoolkit.org/maps/api/geocode/json?sensor=false&address=Downing Street 10, London
Last edited by moshi on April 2nd, 2013, 1:15 pm, edited 1 time in total.
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: free open geocoding apis

Post by moshi »

looks like the Yahoo! api is gone now. :(

but there's an other way to obtain a WOEID or coordinates from Yahoo!

Code: Select all

http://query.yahooapis.com/v1/public/yql?q=select * from geo.places(0,1) where text="Downing Street 10, London"&format=xml
lets hope this one lasts. does not support house numbers or streets (the above example only works because it is a POI).
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: free open geocoding apis

Post by jsmorley »

Very handy... Thanks Moshi.
YahooWOEID_2.0.rmskin
(2.2 KiB) Downloaded 334 times
4-2-2013 12-01-35 PM.png
4-2-2013 11-54-49 AM.png
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: free open geocoding apis

Post by moshi »

nice. i like that you use the type of the administration.

sometimes this would be better (look for San Marino)

Code: Select all

(?(?=.*<admin1 ).*<admin1 .*type="(.*)".*>(.*)</admin1>)
maybe one more piece of information:
geo.places(0,1)
There can be more than one result (when you are for Paris for example), but if you want to read more results, you have to modify the request. here "0" is the start of the index, "1" is the number of results.
caution: something like geo.places(0,5) might mix up results even with conditional statements. (admin1 might not exist for the first result, but in the second, so a more sophisticated RegExp would be required)
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: free open geocoding apis

Post by jsmorley »

moshi wrote:nice. i like that you use the type of the administration.

sometimes this would be better (look for San Marino)

Code: Select all

(?(?=.*<admin1 ).*<admin1 .*type="(.*)".*>(.*)</admin1>)
maybe one more piece of information:
geo.places(0,1)
There can be more than one result (when you are for Paris for example), but if you want to read more results, you have to modify the request. here "0" is the start of the index, "1" is the number of results.
caution: something like geo.places(0,5) might mix up results even with conditional statements. (admin1 might not exist for the first result, but in the second, so a more sophisticated RegExp would be required)
Yes, it can get complex quick, as some areas (particularly if you use a POI) don't have some info like admin1 / admin2 / locality1 / locatlity2 etc.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: free open geocoding apis

Post by jsmorley »

Looks like the api doesn't support it, but what would be really cool would be to enter a Lat/Long and have it "find" the nearest valid weather location code. Sometimes the closest "town/city" seems like it should be correct, but many folks could get even more accurate weather results since there are actually defined locations Yahoo knows about that are not intuitive to the user. For instance, my mailing address is "Fairfax", but "Chantilly" works better for accurate weather.

Lat and Long most folks can get from their phones...
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: free open geocoding apis

Post by jsmorley »

I added that look-ahead to the .rmskin in the post above.

:-)
4-2-2013 12-27-40 PM.png
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: free open geocoding apis

Post by jsmorley »

Darn...
4-2-2013 12-33-14 PM.png
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: free open geocoding apis

Post by jsmorley »

moshi wrote: maybe one more piece of information:
geo.places(0,1)
There can be more than one result (when you are for Paris for example), but if you want to read more results, you have to modify the request. here "0" is the start of the index, "1" is the number of results.
caution: something like geo.places(0,5) might mix up results even with conditional statements. (admin1 might not exist for the first result, but in the second, so a more sophisticated RegExp would be required)
I actually kinda like the single return. Not only is it easier to parse, (by miles) it's not hard to use it that way. If you put in "paris" and meant "Paris Idaho" instead of "Paris France", you will get the wrong one and see that you need to narrow the search.
User avatar
moshi
Posts: 1740
Joined: November 13th, 2012, 9:53 pm

Re: free open geocoding apis

Post by moshi »

the old api could do reverse geocoding, pity it does no longer exist.

one solution would be to use Google (supports coordinates input) first:
http://maps.googleapis.com/maps/api/geocode/xml?address=38.731602,-77.058563&sensor=false
and use the results to query Yahoo. that would need clever formatting and some testing about what input Yahoo accepts to make it work globally.

or (lets hope Kaelri or the Omnimo guys do not read this), you could use OpenWeather instead of Yahoo.
http://openweathermap.org/wiki/API/JSON_API
Post Reply