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

Hello,

I try to use Overpass QL to get all ways in a given area in CSV. I want to have all coordinates of all nodes of each street.

For example:

 node_id_1 lat lon way_id_1 
 node_id_2 lat lon way_id_1 
 node_id_3 lat lon way_id_1 
 node_id_4 lat lon way_id_2
 node_id_5 lat lon way_id_2

I tried several approaches but none worked. I can get all nodes and all ways but I found no way to have an explicit association between nodes and ways. I do not manage to add the way information to each node, and the node list does not appear for each way in the CSV output.

Any help would be appreciated. Thanks.

asked 12 Sep '15, 18:28

haltux's gravatar image

haltux
31112
accept rate: 0%


At this time, it's not possible to have details originating from several OSM objects in one single line. In your case, that's the node id + details, as well as the corresponding way id.

I suggest to take advantage of the foreach statement like in the following example.

It will first output the way id, followed by a list of its nodes with their respective node id and lat/lon details.

[out:csv(::type, ::id, ::lat, ::lon)]
[bbox:{{bbox}}];
way[highway];
foreach(           // for each way tagged as highway=* do...
  out;             // output way id
  node(w);         // determine respective nodes
  out;             // output all node details
);

Try it in overpass turbo: http://overpass-turbo.eu/s/bpj

In a post processing step, you'll have to transform this output to whatever format you need.

Caveat: CSV output does NOT preserve the sequence of nodes per OSM way. Depending on your requirements, the results may therefore be completely useless to you!

CSV output was primarily designed to return tags for relations/way/nodes,.... Returning geometry information for ways was not a main focus. Maybe you want to check JSON/XML output with out geom; instead, which is also rather easily parse-able.

permanent link

answered 12 Sep '15, 19:25

mmd's gravatar image

mmd
5.7k15388
accept rate: 37%

reverted 12 Sep '15, 19:56

OK, thank you. However, if nodes are not ordered, it is actually totally useless for me. Thanks for having pointed that out. I really have to rethink all that, probably start from JSON and generate my own CSV.

(12 Sep '15, 19:54) haltux

By the way, my actual goal was to generate all pairs of nodes (X,Y) such that X and Y are two consecutive points in a way. I guess there is no direct way to do that, but if you have any idea, I would be very interested in it.

(12 Sep '15, 20:00) haltux

Right, I don't see an option to have pairs of consecutive points as an Overpass result. You'll have to implement this in your favorite language based on the JSON/XML output returned by the API.

(12 Sep '15, 20:28) mmd

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:

×65
×42

question asked: 12 Sep '15, 18:28

question was seen: 6,013 times

last updated: 12 Sep '15, 20:28

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