[GIS] Convert OSM to Shapefile

openstreetmapshapefile

How can I convert an OSM file to Shapefile? Is there a good tool or a good web page.

I tried this link https://code.google.com/archive/p/osm2shp/, but there is an error.

Best Answer

If you install the GDAL and OGR tools (open source, available for all major operating systems, see osgeo.org for downloads and details) you can do this on a command line:

$ ogr2ogr maps map.osm

and it will extract the OSM file into an existing folder called "maps" as several shapefiles. Note that OSM layers can contain more than one geometry type, but shapefiles can't, so you might see:

ERROR 6: Geometry type of `Geometry Collection' not supported in shapefiles.  Type can be overridden with a layer creation option of SHPT=POINT/ARC/POLYGON/MULTIPOINT/POINTZ/ARCZ/POLYGONZ/MULTIPOINTZ/MULTIPATCH.

Better to save to a GeoPackage, which can handle Geometry Collection and long field names (another source of shapefile errors):

$ ogr2ogr -f GPKG map.gpkg map.osm
0...10...20...30...40...50...60...70...80...90...100 - done.

now you have a GeoPackage file that contains all the layers which can be read in most major GIS packages.

Related Question