Skip to content

Instantly share code, notes, and snippets.

@dalekunce
Last active September 15, 2019 15:14
Show Gist options
  • Save dalekunce/5d44ddc6257dfa71cbf0 to your computer and use it in GitHub Desktop.
Save dalekunce/5d44ddc6257dfa71cbf0 to your computer and use it in GitHub Desktop.
workflow for cutting part of an osm file

Quick workflow to setup and cut an osm file with a polygon file

##install osmconvert

wget -O - http://m.m.i24.cc/osmconvert.c | cc -x c - -lz -O3 -o osmconvert

##move it to bin folder

cp osmconvert /usr/local/bin/osmconvert

##download ogr2poly.py

wget https://raw.githubusercontent.com/dalekunce/ogr2poly.py/master/ogr2poly.py

##convert json to poly file

ogr2poly.py -v src_datalayer

##download pbf file

wget http://download.geofabrik.de/africa-latest.osm.pbf

##cut osm file with poly layer

osmconvert src_osm_file.pbf -B=json.poly --complete-ways -o=output.pbf

#convert pbf to spatialite

ogr2ogr -f "SQLite" -dsco SPATIALLITE=YES output.db osmfile.pbf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment