1

I want to parse OSM data and to get all buildings with height or building:levels data.

I changed osmconf.ini file to read height and building:levels tags as separate columns for multipolygon layer but after all this i get an error ERROR 1: "height" not recognised as an available field. ERROR 1: SetAttributeFilter(building is not null and (height is not null or building_levels is not null)) on layer 'multipolygons' failed.

This is ogr2ogr command I used ogr2ogr -f "GPKG" -where "building is not null and (height is not null or building_levels is not null)" building_height.gpkg us-latest.osm.pbf multipolygons -progress --config OSM_CONFIG_FILE "C:\\Program Files\\QGIS 3.10\\share\\gdal\\osmconf.ini"

I have no idea why it is not working.

Here is osmconf.ini snippet for mulitpolygons:

[multipolygons]
# common attributes
# note: for multipolygons, osm_id=yes instantiates a osm_id field for the id of relations
# and a osm_way_id field for the id of closed ways. Both fields are exclusively set.
osm_id=yes
osm_version=no
osm_timestamp=no
osm_uid=no
osm_user=no
osm_changeset=no

# keys to report as OGR fields
attributes=name,type,aeroway,amenity,admin_level,barrier,boundary,building,craft,geological,historic,land_area,landuse,leisure,man_made,military,natural,office,place,shop,sport,tourism,industrial,addr:city,addr:state,addr:street,addr:postcode,addr:housenumber,addr:unit, height, building:levels
# keys that should NOT be reported in the "other_tags" field
ignore=area,created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME
# uncomment to avoid creation of "other_tags" field
#other_tags=no
# uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive
#all_tags=yes

[multilinestrings]
# common attributes
osm_id=yes
osm_version=no
osm_timestamp=no
osm_uid=no
osm_user=no
osm_changeset=no

# keys to report as OGR fields
attributes=name,type
# keys that should NOT be reported in the "other_tags" field
ignore=area,created_by,converted_by,source,time,ele,note,openGeoDB:,fixme,FIXME
# uncomment to avoid creation of "other_tags" field
#other_tags=no
# uncomment to create "all_tags" field. "all_tags" and "other_tags" are exclusive
#all_tags=yes 
3
  • 2
    I would initially try without the spaces in the attributes= line. – HeikkiVesanto Mar 31 at 14:35
  • That solved the problem, thanks. – DrJacoby Apr 2 at 9:01
  • I will add it as an answer then. – HeikkiVesanto Apr 2 at 19:59
1

You should remove the spaces from the line:

attributes=name,type,aeroway,amenity,admin_level,barrier,boundary,building,craft,geological,historic,land_area,landuse,leisure,man_made,military,natural,office,place,shop,sport,tourism,industrial,addr:city,addr:state,addr:street,addr:postcode,addr:housenumber,addr:unit, height, building:levels

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.