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

I have a lot of GPS coordinates. How can I find the respective element id according the GPS data? (I can not use the webpage and per the mouse click on the query button, since I have too many points...)

For example:

Given this GPS coordinate: [51.645401, 12.052744]

Return the element id: farmland #6249468

How can I do that?

asked 09 Feb '17, 16:12

xirururu's gravatar image

xirururu
16113
accept rate: 0%

edited 09 Feb '17, 18:12


The query button on the website is implemented using a publicly available service, Overpass-API:

http://wiki.openstreetmap.org/wiki/Overpass_API

There is some discussion of it in the website code:

https://github.com/openstreetmap/openstreetmap-website/blob/e3357b27e61c3ee4f4cf51c87fdc94deeaaa7c6f/app/assets/javascripts/index/query.js#L262

(the query language used there is documented at http://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL )

You can experiment with Overpass-API using a convenient gui at Overpass Turbo:

http://overpass-turbo.eu/s/mC9

I've only added a piece of the query there, the is_in operator returns a subset of nearby objects, you'd need to add the around operators and experiment a bit to see if the output is useful for what you need.

permanent link

answered 09 Feb '17, 23:52

maxerickson's gravatar image

maxerickson
12.7k1083176
accept rate: 32%

@maxerickson Thanks so much for the answer! Run your is_in() function works perfectly. But how can I write the nearby function? According your query.js file, I made the nearby function. But it doesn't work.

(node(around:100, 51.645401, 12.052744); way(around:100, 51.645401, 12.052744));

out tags;

relation(around:10, 51.645401, 12.052744); out;

Here is my code in overpass-turbo

http://overpass-turbo.eu/s/mCa

(10 Feb '17, 01:34) xirururu

There are no features within the 100 meter radius. Increasing it returns some features (200 works for nodes).

Also get rid of the tags from the output statement. That removes the geographic information from the results. out geom will add geographic information for ways and relations.

http://overpass-turbo.eu/s/mCd

(10 Feb '17, 03:12) maxerickson

@maxerickson Thanks! I still have a little doubt, The gps point [51.645401, 12.052744] is actually in the "Farmland #6249468", but why it returned as a nearby feature?

(10 Feb '17, 10:56) xirururu

The areas that the is_in operator returns are generated by Overpass API using a set of rules. For landuse types (and most other features), they are only included as areas if they have a name.

The rules are here: https://github.com/drolbr/Overpass-API/blob/master/src/rules/areas.osm3s

(10 Feb '17, 13:32) maxerickson

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: 09 Feb '17, 16:12

question was seen: 2,863 times

last updated: 10 Feb '17, 13:32

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