1

How would I reliably convert OSM-data (.osm, .kml, .gpx or .geojson) to .shp?
ogr2ogr seems have issues:

geojson:

$ogr2ogr -f "ESRI Shapefile" destination_data.shp export.geojson   
ERROR 6: Can't create field alt_name31 in Shape DBF file. Maximum record length reached.    
Warning 6: Normalized/laundered field name: 'alt_name:fa' to 'alt_name31' 

kml, gpx:

$ogr2ogr -f "ESRI Shapefile" destination_data.shp export.kml  -lco ENCODING=UTF-8   
Warning 6: Normalized/laundered field name: 'Description' to 'Descriptio'   
Warning 1: Value '...' of field Descriptio has been truncated to 254 characters.

And encoding is off.

  • 1
    You are hitting inherent limits in the shapefile format. What do you want to throw away ? Would it be better to just download a pre-shapefile'd version: wiki.openstreetmap.org/wiki/Shapefiles ? – BradHards Jul 1 '17 at 3:55
  • 1
    Ah, I see from your other question that you already had that link. Its still just an inherent limit of the shapefile format though. – BradHards Jul 1 '17 at 4:03
  • If you are looking for polygons Shapefile from OSM like lake or nature reserves have a look in this answer. – Nitzan Matan Jul 1 '17 at 8:09
1

ESRI Shapefile's field name can be up to certain characters limitation. supposed if you try to convert from GeoJSON to Shapefile then try to change your geoJSON property "alt_name31" to "altnam" And try it.

But if you have *.osm file then bellow code may be easily doing your job.

 $ogr2ogr -f "ESRI Shapefile" destination_data.shp export.osm multipolygons

The OSM driver will categorize features into 5 layers: points, lines, multilinestrings, multipolygons, and other_relations. So you have to pass anyone at the end of the command which you desire.

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.