I have a PostGIS database in the "Osm2pgsql/schema".

I get a 7 rows when I query the planet_osm_polygon table with this:

select * from planet_osm_polygon where boundary='administrative' and admin_level = '2' and name = 'Deutschland'

Only 3 of them have a geometry. Unfortunately none of them is the big Germany polygon. They are all enclaves in Belgium or Switzerland. Every single on has an way_area (real type) information. Should I work with this? How?

Or what am I doing wrong? If I do the same for states in Germany, I can't find a single state polygon :(

asked 30 May '12, 14:50

np00's gravatar image

np00
51348
accept rate: 0%


In OSM, polygons, especially large ones, often break because someone makes a small edit somewhere that causes the boundary to be incomplete or self-intersecting, and osm2pgsql may not then be able to build the geometry. It is also possible that the data extract you were using did non contain everything required to build the boundary.

Depending on what you need the polygon for, there are various things you could do.

  • try a different importer, e.g. imposm
  • use a different data processing toolchain altogehter, e.g. osmjs which also builds polygons for you
  • manually retrieve the relation (use a search engine to find "osm relation germany", then issue an API call for /relation/1234/full, then post-process the resulting data - again, depending on what your use case is, perhaps with rel2poly/poly2wkt or something
  • use a third-party web site that assembles relations for you, e.g. for the area of Germany try ags.misterboo.de where you can download any boundary as GeoJSON.

Having said that, on my osm2pgsql-imported database I get exactly one result for e.g. "admin_level='4' and name='Bayern'", and for "admin_level='2' and boundary='administrative' and name='Deutschland'" I get the following list:

 osm_id | way_area 
--------+----------
 -51477 |  49.2627
 -51477 | 0.001543
 -51477 | 0.000241
 -51477 | 0.000123
 -51477 |    2e-06
 -51477 | 0.001275
 -51477 | 0.000915

Indeed the way_area column can be used as an indicator which of those is the "big Germany polygon".

permanent link

answered 31 May '12, 10:17

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
68.3k806211063
accept rate: 24%

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:

×190
×141
×117
×69
×17

question asked: 30 May '12, 14:50

question was seen: 5,226 times

last updated: 31 May '12, 10:17

powered by OSQA