Skip to content

Instantly share code, notes, and snippets.

@definiteIymaybe
Forked from dalekunce/osm_extract_workflow.md
Created September 15, 2019 15:14
Show Gist options
  • Save definiteIymaybe/d8b99fea345cd216fe8b3407698080bb to your computer and use it in GitHub Desktop.
Save definiteIymaybe/d8b99fea345cd216fe8b3407698080bb 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