Hello, on Overpass when I make query and ask for "raw data directly from Overpass API" I get a JSON that contains some extra data that I do not need. For example see the following query:

[out:json][timeout:600]; ( node["shop"="e-cigarette"];>; way["shop"="e-cigarette"];>; relation["shop"="e-cigarette"];>; ); out;

I would like to get all nodes/way/relation that have tag shop and value e-cigarette, so in this way I should get the count of all shop in the world that sell e-cigarettes.

But I get a lot of extra data, such as nodes that are a part of way/relation and ways that are a part of relation and relations theirself as well. So, is it possibile to get just one occurence for every "entity" (node or way or relation) that has some given properties? How to reach that?

asked 04 Mar, 18:00

Andreanovenove's gravatar image

Andreanovenove
1266917
accept rate: 0%


Remove ">;" from every line and you should get what you request.

That statement substantially means "get all the objects referenced by the one you have found". For more info: https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Recurse_down_.28.3E.29

permanent link

answered 05 Mar, 10:44

MarcoR's gravatar image

MarcoR
2313513
accept rate: 16%

Thank you for your reply. Yes, it works, but I would like to get a couple of coordinates for every point (node/way/relation). I know that a way or relation could have several coordinates, do you know if is it possible to get just one couple of lat and lon for every object? Then every object should have "type", "id", "lat", "lon" and "tags".

(05 Mar, 18:23) Andreanovenove
1

Try out center; instead of out.

It calculates the center of the bounding box of the feature or so, so it might not work if you want a better centroid than that.

(05 Mar, 19:46) maxerickson

I did see it, from here: https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Standalone_queries. Do you know what does the note mean? "Note: The center point is not guaranteed to lie inside the polygon". Anyway it seems to work but I have to double check it. Thank you so much for your help!

(05 Mar, 20:06) Andreanovenove

That's what maxerickson was talking about. Think about an object shaped like a horseshoe. The centre of the bounding box would be in the middle of the open area, not inside the actual area of the object.

(05 Mar, 21:45) alester

Oh, I see. The horseshoe example opens my mind about the meaning of that note. Thank you. Do you know a way to get just the first couple of coordinates or any of the nodes' coordinates corrisponding to a way/relation instead of calculated center?

(06 Mar, 17:22) Andreanovenove
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:

×340
×116
×111
×62
×19

question asked: 04 Mar, 18:00

question was seen: 244 times

last updated: 06 Mar, 17:22

powered by OSQA