[GIS] Convert an OSM file to a Shapefile with the same attributes

ogr2ogropenstreetmapshapefile

I am trying to use OGR2OGR to convert an .osm file to a .shp file:

ogr2ogr.exe --config OSM_USE_CUSTOM_INDEXING NO -skipfailures -f "ESRI Shapefile" output.shp input.osm

OGR2OGR does this pretty nicely, and converts the .osm file to four .shp files in the "output.shp" folder: lines.shp, multilinestrings.shp, multipolygons.shp, points.shp.

What I would like to do, is to force all four resulting .shp files to have equal number of attributes (or "keys" in openstreetmap terminology).
For example, a polygon would certainly not have an attribute highway. While a line could have. But I still want to force the multipolygons.shp file to have the highway attribute.
To make it clear, I am not interested in specific attributes.
I would just want all of the upper 4 .shp files to have the same attributes, and the same number of attributes.

Can this be done somehow by editing the upper command?
Or is this exclusively done by editing the osmconf.ini file? If yes, then how?

Best Answer

The osmconf.ini file has a separate sections for defining the attributes for each layer (points, lines, multipolygons, multilinestrings, other_relations). This is the default setting for the "points" layer.

[points]
# 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,barrier,highway,ref,address,is_in,place,man_made
# keys that, alone, are not significant enough to report a node as a OGR point
unsignificant=created_by,converted_by,source,time,ele,attribution
# keys that should NOT be reported in the "other_tags" field
ignore=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

If you copy-paste and use the same settings for all layer sections in osmconf.ini you will get the same set of attributes for all the layers.