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

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 '19, 18:00

Andreanovenove's gravatar image

Andreanovenove
126101118
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 '19, 10:44

MarcoR's gravatar image

MarcoR
6873820
accept rate: 23%

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 '19, 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, 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 '19, 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 '19, 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 '19, 17:22) Andreanovenove

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:

×483
×228
×147
×85
×28

question asked: 04 Mar '19, 18:00

question was seen: 2,824 times

last updated: 06 Mar '19, 17:22

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