Skip to content

Instantly share code, notes, and snippets.

@maxerickson
Created July 27, 2017 01:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxerickson/32ca41e72458b12a5734f97f75800448 to your computer and use it in GitHub Desktop.
Save maxerickson/32ca41e72458b12a5734f97f75800448 to your computer and use it in GitHub Desktop.
#! /bin/bash -x
# transform USFS tag scheme to osm tags
INFILE=$1
OUTFILE=$2
INLAYER=$(basename $INFILE)
INLAYER=${INLAYER%.*}
OUTLAYER=$(basename $OUTFILE)
OUTLAYER=${OUTLAYER%.*}
# select interesting columns, create osm fields
ogr2ogr -overwrite -sql "select 'FS ' + ID as ref, NAME as name, SYMBOL_COD as fscode, '' as highway, '' as surface from $INLAYER" -f "ESRI Shapefile" $OUTFILE $INFILE
#tracks
ogrinfo $OUTFILE -dialect SQLite -sql "update $OUTLAYER set highway='track' where fscode = '106'"
# dirt, gravel, paved roads
ogrinfo $OUTFILE -dialect SQLite -sql "update $OUTLAYER set highway='unclassified', surface='dirt' where fscode = '515'"
ogrinfo $OUTFILE -dialect SQLite -sql "update $OUTLAYER set highway='unclassified', surface='paved' where fscode = '517'"
ogrinfo $OUTFILE -dialect SQLite -sql "update $OUTLAYER set highway='unclassified', surface='gravel' where fscode = '518'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment