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.


That is indeed a good and fundamental questions!

If there is no similar topic asked at 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 ( ),

so try to start at


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 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.


Read …

… and/or look at this URL:

And please also take this into account:

You should be able to figure it out from here.


You can do it with GDAL.

gdallocationinfo frmt_wms_openstreetmap_tms.xml -wgs84 27.12 69.13
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.