0

I've been attempting to export boundary information from an OSM file. My process is nearly there however I have an issue with the polygon I'm generating drawing random lines.

I would appreciate some insight on where I may be going wrong.

Step 1: Export the OSM data into XML

osmfilter -v greater-london-latest.osm --keep="boundary= admin_level= place="  > b.txt

Step 2: Run a script to process the XML.

cycle each relation node
 load the member ways
   load the nodes from each specified way
    record the lat/lon and build a poly set

This produces a series of lat/lon which when I build them as a polygon give the correct overall shape I'm looking for. However, there are issues with the connecting lines I assume..

My polygon output

I'm actually looking for this, which is similar but Im obviously missing something.

Actual Poly Im looking to generate

Again, thanks for any help.

user6316291
  • 81
  • 1
  • 3
  • Does this answer your question? [OSM to Google Maps polygons](https://stackoverflow.com/questions/36704706/osm-to-google-maps-polygons) – geocodezip Sep 14 '20 at 19:56

1 Answers1

0

Ways in relations are not necessarily sorted. See answers to this question on how to sort ways, especially the answer by user geocodezip.

Alternatively you can make use of various tools/libraries to do the sorting for you. Unfortunately I can't point you directly to one but there are various tools capable of sorting relation members, including the OSM website itself, JOSM, overpass turbo (I guess), some JS stuff, [...]. Maybe some other user can help out with pointing to some good examples?

scai
  • 20,297
  • 4
  • 56
  • 72