I try to create multipolygon describing border of Poland to test if some building are in this administration area. I took data from db (I imported OSM data to local db first preserving order of ways and nodes during the import). What I see is some ways in relation definition (members) are not on proper position.
More info is here. I can't load images to this post because of insufficient reputation points...

The question is: should I reorder ways on relation data or it's an issue with Geofabrik data export and look for other source of OSM data?

asked 21 Jul '16, 12:20

stalek's gravatar image

accept rate: 0%

Do not write your own multipolygon building code. You are re-inventing the wheel. Re-use the code that already exists in osm2pgsql (PostGIS importer), libosmium (C++ processing library with Python bindings), or GDAL (has an OSM input driver and can write various output formats) instead!

OSM does not require that relation members be stored in the right order; this is something the software must do.

permanent link

answered 21 Jul '16, 12:28

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
accept rate: 23%


In addition, even if you were to make sure that all objects in a relation (such as a route relation) were "in order", as soon as someone edits that relation (e.g. to split a way) the objects will be "out of order" again.

(21 Jul '16, 12:40) SomeoneElse ♦

I don't plan to draw any shapes. I have to test if some coordinates belong to some administration hierarchy (country, region, county and so on). To do it I have to create the shape of boundary to test if any point/location is withing such shape. I will take a look if PostGIS importer creates such shapes during the import (as mentioned by you). It's not a rocket science to reorder ways when I know they are in random order. btw: I use SqlServer and its spatial support to speed up things during the processing and I don't load any data to any external applications to not slow it down (it's not necessary in reality, because every complex operation on such data is easy to implement using T-SQL). It's like using many "db engine cursors" in case of external apps versus raw performance of group of queries optimized by DB engine :)

Thanks for the info :)

(21 Jul '16, 13:41) stalek

After reordering of a few ways/lines I received proper shape already, so the info from Frederik helped :)

alt text


(21 Jul '16, 14:20) stalek
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



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:


question asked: 21 Jul '16, 12:20

question was seen: 2,366 times

last updated: 21 Jul '16, 14:22

powered by OSQA