views:

2138

answers:

3

I wonder if there is any API I could query OSM data through, for example; Are (lon_1, lat_1) at land or at sea? Or could it be possible to get an island as a well-defined polygon? The only usage I've seen so far has just been tools for rendering OSM data (generating tiles).

Update:

I've found a great API for reading Openstreetmap data; Mapscript. This is an interface to MapServer, which is able to read *.map and *.shp files, and is very, very fast.

+1  A: 

Of course, the javascript api is called openlayers.

ko-dos
I know about openlayers, but isn't that just for displaying/operating on rendered tiles?
Yngve Sneen Lindal
+8  A: 

Yes, there is an api and xpai (extended api). I havent used these yet.

But there is also the cloudmade api to OSM. I played a bit with the python api. I am not sure, if any of them could help you with your particular problem, but you could search for a coastline near to your point. If your point is within the polygon tagged natural=coastline, you have an island (or a continent)...

vikingosegundo
Ok, thanks for the tip.
Yngve Sneen Lindal
don't hesitate to vote up, if it was an useful answer
vikingosegundo
What is the XML format it delivers and how would I render that into a raster image in my application?
Matthew Lock
to generate a iamge from the xml u need a renderer. there a several. see here http://wiki.openstreetmap.org/wiki/Renderers
vikingosegundo
+2  A: 

You can use CloudMade's Geocoding API to search for an island in the OpenStreetMap data. The API will return the geometry of the result by default, and this sounds to me what you are looking for. For example, Arran off the coast of Scotland can be found by the following http request:

http://geocoding.cloudmade.com/BC9A493B41014CAABB98F0471D759707/geocoding/find/Arran,UK.js?results=1

(and as a neat little hack, changing the .js to .html previews the result.

More docs and examples on the API are at developers.cloudmade.com/projects/show/geocoding-http-api If you don't want to use the http api, then abstraction APIs are available in multiple languages - ruby, python, perl and others.

gravitystorm