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

Hello,

I need to have order of nodes within a way. For instance:

<way id="10053349">
<nd ref="4534884733"/>
<nd ref="4534884725"/>
<nd ref="4534884748"/>
<nd ref="82608659"/>
<nd ref="82608658"/>
<nd ref="639108039"/>
<nd ref="3451083060"/>
<nd ref="345553449"/>
<nd ref="345553447"/>
<nd ref="345553431"/>
<nd ref="3451083057"/>
<nd ref="345553432"/>
<nd ref="345553433"/>
<nd ref="345553434"/>
<nd ref="345553435"/>
<nd ref="3451083068"/>
<nd ref="345553436"/>
<nd ref="29564147"/>
<nd ref="345553437"/>
<nd ref="345553438"/>
<nd ref="3451083079"/>
<nd ref="345553439"/>
<nd ref="3451083082"/>
<nd ref="345553440"/>
<nd ref="1326631485"/>
<nd ref="82608663"/>
<nd ref="82608662"/>
<nd ref="4534884733"/>
<tag k="addr:housenumber" v="21"/>
<tag k="addr:street" v="Arcisstraße"/>
<tag k="amenity" v="university"/>
<tag k="building" v="yes"/>
<tag k="name" v="1"/>
<tag k="wheelchair" v="yes"/>

</way>

I need to retrieve only a list like following from above code:

4534884733 4534884725 4534884748 82608659 82608658 639108039 ...

I tried to use osmfilter and osmconvert, but could not find any command. Any suggestions? I need this for an application where the order of latitudes and longitudes is important.

Thanks

asked 22 Jul '17, 00:51

omidrad's gravatar image

omidrad
21112
accept rate: 0%


Your question does not make a lot of sense for the following reasons:

  • The order of nodes is significant for everyone who processes a way, not just for your application.
  • You can trivially convert the list of node IDs into a textual form with a few lines of code in a scripting language of your choice (Perl: cat myfile | perl -ne 'END { print join(" ", @nid)."\n"; } push(@nid,$1) if (/<nd ref="(\d+)"/);' or shell: cat myfile | grep "<nd ref"|cut -d\" -f2|xargs echo) but is that really your question? The list of Node IDs is not a list of latitudes and longitudes.

If you are hoping to extract a sequence of latitudes and longitudes for all nodes in a way, then the easiest way is to run your OSM XML file (which of course has to have the matching node data referenced by your ways) through the osmium command line tool, writing out an XML file with the osmium specific locations_on_ways option.

permanent link

answered 22 Jul '17, 10:16

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

Thanks a lot for the reply.

Actually I have a csv file containing 3 columns : ID, lat and lon of a building footprint which I obtained using osmconvert. I have loaded this csv file into a list in my Java code.

However, the order of the lats and lons are not sorted to form a correct polygon of the footprint. I wanted to have the correct sequence using the ref values of the way to sort the list in my Java code.

(22 Jul '17, 11:22) omidrad
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:

×710
×60
×47

question asked: 22 Jul '17, 00:51

question was seen: 3,148 times

last updated: 22 Jul '17, 11:22

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