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

Svavar Kjarrval svavar at kjarrval.is
Thu Dec 20 15:23:15 GMT 2012


On 20/12/12 14:47, Jon Burgess wrote:
> 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.
I imported the data myself and made sure they formed a complete ring
before submitting.

Checked the data in the main OSM database and for some reason Garðabær
didn't form a complete ring. However, Hafnarfjörður and Mosfellsbær do.
Reykjavík forms two rings since it's two separate areas.
>
>> 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.
Because of the error, I got another copy of iceland.osm.bz2 today (dated
the 19th). The state.txt file was backtracked to the 18th and an update
executed. The data is from after I updated, which was this noon. I
wonder if there's a difference between the osm.bz2 version and the
osm.pbf one. The boundary data is from some weeks ago anyway.

I corrected the ring for Garðabær and waited for the next update, it
didn't appear in the osm_polygon table. I assume entries are moved or
recreated in the other table if osm2pgsql detects that they should be
elsewhere.
>
>> 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
I downloaded the data this noon and these are the results. The osm.bz2
file is dated the 19th and the osm.pbf is dated today. These seem to be
two very different versions because I don't think so many changes have
been made for Iceland in that short amount of time.
>
>> With regards,
>> Svavar Kjarrval
>> _______________________________________________
>> dev mailing list
>> dev at openstreetmap.org
>> http://lists.openstreetmap.org/listinfo/dev
>
With regards,
Svavar Kjarrval


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20121220/9e9a6758/attachment-0001.pgp>


More information about the dev mailing list