NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

So I have been trying to get a query that shows data that is within a coastline like foreach(way._["coastline"]);is_in(47.995206,-122.225926);out; but it returns state and country data even though I use coord's outside of a coastline. I would just like to know if the coord is on land or not. Any ideas?

asked 20 Oct '13, 08:12

JacobKukuk's gravatar image

JacobKukuk
6111
accept rate: 0%


It is not possible to find out whether a coordinate is on land through the Overpass API, or any other OSM driven web service that I know of. The main reason for that is that land/water areas are not kept in OSM as polygons. The perfect solution for your problem would be to load the OSM coastline polygons from www.openstreetmapdata.com into a spatial database and make a query to that database. A less-than-perfect solution would be computing which tile your coordinate is on, loading that tile from an existing tile server, and checking whether the corresponding pixel is blue.

For the tiles@home project, we used to keep an "index PNG file" of, I believe, 4096x4096 pixels for the whole world (corresponding to one pixel per zoom level 12 tile) that would say whether a certain tile is fully water, fully land, or had coastline in it. Such a PNG file is relatively small and easy to query so maybe if your precision requirements aren't high, you could revive that old technology.

permanent link

answered 20 Oct '13, 09:42

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

Thanks for your response, looks like i'm just going to setup a postgis that returns true or false if lat long is over land from a shape file. Thanks for pointing me in the right direction.

(20 Oct '13, 23:53) JacobKukuk

To add this this if you are making a postgis query you can use this query with http://openstreetmapdata.com/data/land-polygons. This will return true or false.

Also Make point is somewhat backwards, instead of lat long its long lat... ST_MakePoint(Long, Lat)

select (count(*) >0) as isLand from "land_polygons" where 
ST_Intersects(ST_MakePoint(-122.222863,47.999535), geom);
permanent link

answered 21 Oct '13, 01:19

JacobKukuk's gravatar image

JacobKukuk
6111
accept rate: 0%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×8

question asked: 20 Oct '13, 08:12

question was seen: 3,510 times

last updated: 21 Oct '13, 01:19

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum