How to know one point is ocean or land?

When I sent a osm map request for a tile (a small geo region in square), I got empty osm xml file if the small geo region is inside of ocean, but How I know it is ocean or land when I want to draw map for the small geo region?

Any information is appreciated. Thank you very much.

Simon

That is indeed a good and fundamental questions!

If there is no similar topic asked at http://help.openstreetmap.org yet, I would try to enter into OSM data structure about the special cases of coastlines. Maybe with any geospatial queries you can determine whether a certain position is land or water.

I assume that you are familiar with the OSM elements ( http://wiki.openstreetmap.org/wiki/Elements ),

so try to start at http://wiki.openstreetmap.org/wiki/Coastline

and http://wiki.openstreetmap.org/wiki/OSMCoastline

I’d say for using subsets of the database we’re assuming the user (human or not) to know where he is. The other option would be to add is_in=* to every object, which still wouldn’t solve the problem of an empty dataset.

Two alternatives came into my mind.

  • Download the land polygons shapefile and check with them if your area is land or sea http://openstreetmapdata.com/data/land-polygons. It may still fail if you hit in the middle of a big lake.
  • Query the pixel values from the OSM slippy map service by your coordinates. If RGB value is of a water colour, it is water.

That’s the solution I intend to use for my own rendering software which also has that problem (didn’t get around to coding it yet). In a tiled system, it’s sufficient only store one water/not(-entirely)-water bit for the entire tile.

Lakes are also a problem, but separate one, I believe - due to the special treatment of coastlines in OSM it has more in common with being in the middle of a forest than with being in the middle of an ocean.

I appreciate for your answers.

I am interested in the solution of “- Query the pixel values from the OSM slippy map service by your coordinates. If RGB value is of a water colour, it is water.”

Could you please give me more information about this, is there is any programing API to query OSM Slippy map? I know the current location I am query, do I need send http request to some server?

Thank you again.

Simon

Read …
http://wiki.openstreetmap.org/wiki/Slippy_Map
http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames

… and/or look at this URL:
http://a.tile.openstreetmap.org/10/530/331.png

And please also take this into account:
http://wiki.openstreetmap.org/wiki/Tile_usage_policy

You should be able to figure it out from here.

Hi,

You can do it with GDAL.

gdallocationinfo frmt_wms_openstreetmap_tms.xml -wgs84 27.12 69.13
Report:
Location: (38609966P,15483545L)
Band 1:
Value: 242
Band 2:
Value: 239
Band 3:
Value: 233

For using from a program either -xml or -valonly option is probably better.