I am downloading an osm.pbf file from the Geofabrik download server and running the following command:
ogr2ogr -f GPKG norcal-latest-multipolygons.gpkg norcal-latest.osm.pbf -sql "SELECT * FROM multipolygons"
The resulting output seems to be missing several polygons. For example, way-404851503 is absent. However, if I edit the query to specifically filter on that one record in particular, it is able to find it:
ogr2ogr -f GPKG norcal-latest-multipolygons.gpkg norcal-latest.osm.pbf -sql "SELECT * FROM multipolygons where osm_way_id=404851503"
I found that if I change the query to the following, there are an additional 1,821 records, including the specific polygons that I were missing. I think that this is all of the records.
select * from multipolygons where osm_way_id is not null UNION ALL SELECT * FROM multipolygons where osm_id is not null
All of the missing records I have found so far appear to be closed ways. How can this happen? Under what circumstances would running a query with no filter be excluding records? How can I be sure that the resulting GPKG includes ALL multipolygons from the osm.pbf file?