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


I'm looking for a way to get lines of an administrative level (f.e. 4) with no duplicate parts.

When I select all lines from planet_osm_line where admin_level=4 (within a specific country, in this case Papua new guinea) then I get the following: 5 records with osm_id=-311772, that I don't want because they duplicate the geometry of the adjacent level-4 polygon 1 record with osm_id=284884115, which is good no record with osm_id=352439111, which is not good, it's part of the boundary of that polygon.

Some links: full polygon: part in the result-set: missing part: The missing part is a river which also is the boundary of that polygon.

Is this something that has to be fixed in the osm2pgsql config (style-file)? relevant part: node,way admin_level text linear

or is there some query where I can include the missing parts easily?

asked 19 Sep '16, 21:53

Paulosm2016's gravatar image

accept rate: 0%

edited 19 Sep '16, 21:54


Whenever I need boundaries, I use

(20 Sep '16, 04:17) escada

After searching a bit more, this could ofcourse also be a data-error...

(20 Sep '16, 07:37) Paulosm2016

I really don't understand the question. What exactly is going wrong?

You get 5 records of relation (polygon) 311772, but that's no problem? You seem to call way 284884115 a polygon, but that's just a line. Or is the problem that way 352439111 is missing from the polygon 311772?

(Boundaries are relations which are built upon ways. So it is perfectly normal that a way is called by several relations.)

(21 Sep '16, 14:03) joost schouppe

The more I think about it, the more convinced I am that it's a data issue, but I don't know enough of the rules to be sure.

Should there be a way with the same geometry as way 352439111, and that way having admin_level and boundary tags?

(22 Sep '16, 08:59) Paulosm2016

After more investigation I'm getting to the conclusion that I don't understand how to render administrative boundaries where f.e. a river is used to define part of the boundary (there doesn't seem to be an admin_level tag in that case), so if anyone can answer me that, I think it would answer my main question

(22 Sep '16, 15:21) Paulosm2016

I finally figured it out. I join the planet_osm_line l table with the planet_osm_rels r on>array_append(NULL,l.osm_id) and hstore(tags)->'boundary' ='administrative' From there I can make my selection without duplicate lines

permanent link

answered 27 Sep '16, 08:24

Paulosm2016's gravatar image

accept rate: 0%

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]( "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: 19 Sep '16, 21:53

question was seen: 2,552 times

last updated: 05 Jul '17, 08:11

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