Skip to content

Instantly share code, notes, and snippets.

@mappingvermont
Created April 4, 2017 20:56
Show Gist options
  • Save mappingvermont/27f83b1c8b6c1dee037b05c60901cc89 to your computer and use it in GitHub Desktop.
Save mappingvermont/27f83b1c8b6c1dee037b05c60901cc89 to your computer and use it in GitHub Desktop.
Combine all shapefiles in directory, selecting only features where GRID_ID (or DN) is = 1
#!/bin/bash
echo "here"
DATA=`find . -name '*.shp'`
ogr2ogr -a_srs EPSG:4326 merge.shp
for i in $DATA
do
SHP=${i:2:100}
FINAL="${SHP/.shp/}"
echo $FINAL
echo $i
ogr2ogr -append -update merge.shp $i -f "Esri Shapefile" -dialect sqlite -sql "SELECT * FROM $FINAL WHERE DN = 1"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment