[OSM-dev] osm2pgsql - some polygons not ending up in osm_polygon

Jon Burgess jburgess777 at gmail.com
Thu Dec 20 14:47:08 GMT 2012


On Thu, 2012-12-20 at 13:58 +0000, Svavar Kjarrval wrote:
> Hi.
> 
> Yep, another post about osm2pgsql in a short interval.
> 
> I've managed to convert the Iceland extract I got from geofabrik into
> a postgis database. There's however a snag. It seems like not all of
> the data ended up in the correct tables.
> 
> The line I used to import the data:
> osm2pgsql -d osm --cache-strategy sparse
> -S /[workdir]/osm/mapnik-stylesheets/default.style --prefix osm --slim
> iceland.osm
> * Some of the path replaced with [workdir].
> * The import log follows as an attachment.
> 
> Many municipalities went into osm_rels while the others went into
> osm_polygon. The municipalities are all defined with type=boundary and
> admin_level=6. I didn't see anything obvious which might cause
> osm2pgsql to categories them differently.

The most likely reason they would not make it into the polygon table is
if the data does not form a complete ring. In this case they are sent to
the line table instead. If you know the ID of the relation then you can
find the data in the line or polygon tables with osm_id = -relation_id.

> Kind of the same thing happens with some of the suburbs in Reykjavík
> since most of them ended up in osm_polygon, but not all.
> 
> You can see it on
> http://osm.is/?zoom=11&lat=64.10315&lon=-21.82199&layers=B000FTF . The
> area should mostly be filled with a transparent(ish) blue layer. You
> can see the desired effect on
> http://layers.openstreetmap.fr/?zoom=11&lat=64.10315&lon=-21.82199&layers=B00FFFFFFFFFFTFFFFFFFFF .
> 
> SELECT name, admin_level,boundary FROM osm_polygon WHERE admin_level =
> '6'
>          name
>       admin_level
>        boundary
> Álftanes
> 6
> administrative
> Seltjarnarnes
> 6
> administrative
> Kópavogur
> 6
> administrative
> Hrísey
> 6
> administrative
> Hríseyjarhreppur
> 6
> administrative
> 
> The top 3 municipalities in the table are in the capital area in
> Iceland. The ones that should be there too are Hafnarfjörður,
> Garðabær, Reykjavík and Mosfellsbær.

I just repeated this locally with current iceland.osm.pbf from Geofabrik
and get:

gis=# SELECT name, admin_level,boundary FROM iceland_polygon WHERE
admin_level = '6' order by name;
       name       | admin_level |    boundary    
------------------+-------------+----------------
 Álftanes         | 6           | administrative
 Álftanes         | 6           | administrative
 Garðabær         | 6           | administrative
 Hafnarfjörður    | 6           | administrative
 Hrísey           | 6           | administrative
 Hríseyjarhreppur | 6           | administrative
 Kópavogur        | 6           | administrative
 Mosfellsbær      | 6           | administrative
 Reykjavík        | 6           | administrative
 Reykjavík        | 6           | administrative
 Seltjarnarnes    | 6           | administrative
(11 rows)

Looks like all the ones you listed appear now.


> The table parameter in the stylesheet file (in case someone asks):
> (select way,name from osm_polygon where boundary='administrative' and
> admin_level='6' ) as admin
> 
> Is there a osm2pgsql parameter I'm missing in the import or some other
> apparent implementation fault of mine?
> 
The output you attached indicates that you had less data in your file:

Yours:
Node stats: total(1147968), max(2076135241) in 18s
Way stats: total(101787), max(197363513) in 17s
Relation stats: total(2381), max(2649305) in 12s

Mine:
Node stats: total(1222634), max(2074844232) in 5s
Way stats: total(105203), max(197203875) in 5s
Relation stats: total(2429), max(2647535) in 5s

Maybe try downloading the data again?

I'm using this file:

$ ls -l iceland.osm.pbf
-rw-rw-r--. 1 jburgess jburgess 10832119 Dec 20 02:38 iceland.osm.pbf


> With regards,
> Svavar Kjarrval
> _______________________________________________
> dev mailing list
> dev at openstreetmap.org
> http://lists.openstreetmap.org/listinfo/dev





More information about the dev mailing list