Converting/shp to osm using grass and gpsbabel
Jump to navigation
Jump to search
It has been proposed that this page or section be merged with Converting map data between formats. (Discuss)
Imports and automated edits should only be carried out by those with experience and understanding of the way the OpenStreetMap community creates maps, and only with careful planning and consultation with the local community.
See Import/Guidelines and Automated Edits code of conduct for more information. Imports/automated edits which do not follow these guidelines might be reverted!
See Import/Guidelines and Automated Edits code of conduct for more information. Imports/automated edits which do not follow these guidelines might be reverted!
Required software:
In this example, the used files are stored in "C:\OSM\SHP\": kommunal.shp, kommunal.dbf, kommunal.sbn, kommunal.sbx, kommunal.prj.
"kommunal.shp" contains a street-network with very high accuracy - JOSM couldn't handle this...
Generalisation using GRASS:
Main article Simplifying OSM Shapefiles using GRASS (merge?)
- Put your shapefile including all belonging data (dbf etc.) to a fixed directory.
- Switch to command-line (start - run - cmd).
- Switch to GRASS-binary directory, e.g. cd C:\GRASS\bin\
- Remove possible existing maps (be careful): g.remove vect=OSM
- Load the shapefile to a GRASS-map: v.in.ogr -o dsn=C:\OSM\SHP\kommunal.shp out=OSM
- Reduce the amount of nodes: v.generalize input=OSM output=OSM_douglas_reduction method=douglas_reduction threshold=0 reduction=50 -c
- Write a new shapefile: v.out.ogr input=OSM_douglas_reduction dsn=C:\OSM\SHP\reduced olayer=kommunal_reduced
- Remove the GRASS-map: g.remove vect=OSM
Conversion to .osm using GPSBabel
- Switch to GPSBabel-binary directory, e.g. cd C:\GPSbabel\
- Check the shapefile's databse for street-names or other important data: gpsbabel.exe -i shape,name=? -f C:\OSM\SHP\reduced\kommunal_reduced.shp
- Here, STR_NAME contains the name of the streets. (This may not work if the field name is "name"?)
- Write an OSM-file: gpsbabel.exe -i shape,name=STR_NAME -f C:\OSM\SHP\reduced\kommunal_reduced.shp -o OSM -F C:\OSM\SHP\reduced\kommunal.osm
- This shapefile is already in EPSG:4326 = WGS84 and can be read by JOSM.
- Remove GPSBabel's tag from OSM file to save memory:
- Open your OSM-file with notepad
- Remove this tag: <tag k='created_by' v='GPSBabel-1.3.5'/>