[Tile-serving] [openstreetmap/osm2pgsql] Unexpected output: no polygon for specific OSM relation. (#1372)

Alexey Grachev notifications at github.com
Mon Dec 14 21:55:31 UTC 2020


Hello,

I have an issue with osm2pgsql results after loading PBF file to DB.

>    what you are trying to achieve in the end,

I want to load administrative boundaries of the US counties into DB.

>    what you did,

Ways to reproduce. 
1. Download PBF file for New York state from here http://download.geofabrik.de/north-america/us/new-york.html
2. Filter objests you're interested in by osmium
`osmium tags-filter new-york-latest.osm.pbf n/place=city,town,village,hamlet,county r/admin_level=4,5,6,7,8,9,10 --overwrite --verbose -o filtered-new-york-latest.osm.pbf`
3. Load filtered file to DB
` /usr/local/bin/osm2pgsql -p osm -H 192.168.1.3 -P5432 -d dbname -U dbuser -W -c  --slim -l --verbose -G --keep-coastlines  filtered-new-york-latest.osm.pbf`
4. Check counties' borders by DB query
`SELECT name, way FROM osm_polygon WHERE admin_level = '6' order by name;`


>    what behaviour you expected from osm2pgsql,

I expected osm2pgsql created polygons for all counties from the NY state in osm_polygon table. 

>    and what happened instead.

Not all of counties have related polygon in DB.
![изображение](https://user-images.githubusercontent.com/2371914/102139020-564acf00-3e6e-11eb-821a-7351fdd9cce5.png)
You may see the gaps in territory. This is an example of the absent county https://www.openstreetmap.org/relation/1804311#map=10/43.0333/-77.5607
Its data exists in the PBF file. It's possible to check it by command
`osmium show filtered-new-york-latest.osm.pbf `

Also all relevant objects exist in DB,  but not merged into the boundary polygon. It can be checked by such query
```
with rel_members as ( 
	select unnest(parts) id 
	from osm_rels 
	where id = 1804311
),
way_members as (
	select w.id way_id, unnest(nodes) as node_id
	from rel_members m 
	left join osm_ways w on w.id=m.id
)
select st_collect( coalesce(l.way, p.way, ST_GeographyFromText('Point(' || lon/10000000.0 || ' ' || lat/10000000.0 || ')'))::geometry)
from rel_members m 
left join osm_line l on l.osm_id=m.id
left join osm_point p on p.osm_id=m.id
left join way_members w on  w.way_id=m.id
left join osm_nodes n on n.id=w.node_id;
```
![изображение](https://user-images.githubusercontent.com/2371914/102139432-e2f58d00-3e6e-11eb-9783-63a279c3aaca.png)

So it's seems to be an osm2pgsql issue, but not PBF file incompleteness issue. Is there a way to debug this issue, having not edited the C++ code?

osm2pgsql is built from source from the github release v1.4.0 tar. 


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/osm2pgsql/issues/1372
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/tile-serving/attachments/20201214/3d2f0003/attachment.htm>


More information about the Tile-serving mailing list