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

Hi -

sorry if this question seems stupid. Given a lat/lon coordinates, I'd like to known if the point is in a lake, in a forest or on an highway for instance.

Nominatim geocoding gives me the nearest node thus it does not really answer my need.

What's the right way / tool to use to get that ?

Thanks a lot for your help

-- david

asked 02 Mar '16, 13:23

dmercier90's gravatar image

dmercier90
76227
accept rate: 0%

edited 02 Mar '16, 14:30


This is exactly what "query feature" on the http://osm.org/ map does, using Overpass Turbo:

[timeout:5][out:json];is_in(lat,lon)->.a;way(pivot.a);out tags geom({{bbox}});relation(pivot.a);out tags bb;

Where you need to replace lon and lat with the coordinates of the point, and replace {{bbox}} by the current map bounding box (if you need that). This gives you the elements surrounding the given point. Note that this also returns administrative boundaries (county, state, etc.), not just physical elements - you'd need to filter on this, perhaps by throwing away boundary relations etc. See e.g. this query - note that the largest enclosing feature is the entire country.

Also, this will give you enclosing features - so for a highway (which is usually an unclosed way), you wouldn't get a usable result. For that, you may need the other query, "nearby features":

[timeout:5][out:json];(node(around:radius,lat,lon);way(around:radius,lat,lon));out tags geom({{bbox}});relation(around:radius,lat,lon);out geom({{bbox}});

Again, you need to replace lon,lat,{{bbox}}, and in addition radius (how far from the point to look, not sure of the unit) with your data. See e.g. this query - note that by setting the radius too high, there will be many objects; but with a radius too low, there may not be anything found. Depending on your goal, perhaps you might want to start out small and increase the radius in a few steps.

Pay attention also to the freshness data returned with results - Overpass uses its own cache, and updates it from the main db; this can sometimes take days, so newest edits may not be returned in the results immediately.

permanent link

answered 02 Mar '16, 14:44

Piskvor's gravatar image

Piskvor
1.3k91535
accept rate: 37%

edited 02 Mar '16, 16:51

Thanks a lot for your fast answer Piskvor !

I'm going to have a look at Overpass, it seems it will help for sure. Btw I didn't found any access to overpass API from http://osm.org, maybe something's missing me or I didn't understand. As far as I know osm.org reverse geocoding is using Nominatim, not Overpass.

Example queries you have provided will be very usefull, thanks again.

(02 Mar '16, 15:00) dmercier90
3

Overpass is accessed when you use the "Query features" tool, the "?" at the bottom of the right button bar.

(02 Mar '16, 15:11) maxerickson

Thanks Maxerickson, I'm going to change my glasses :)

(02 Mar '16, 15:24) dmercier90

To correct answer, it seems is_in takes (lat,lon), not (lon,lat)

(02 Mar '16, 16:27) dmercier90

Thanks, good catch! Silly me, edited.

(02 Mar '16, 16:49) Piskvor
Your answer
toggle preview

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:

×213
×144
×133
×85

question asked: 02 Mar '16, 13:23

question was seen: 7,544 times

last updated: 02 Mar '16, 16:51

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