Skip to content

Instantly share code, notes, and snippets.

@sgibbes
Forked from mappingvermont/combine.sh
Created April 5, 2017 14:32
Show Gist options
  • Save sgibbes/1d1fa58f2d93ebeb4a40161ec01cfff1 to your computer and use it in GitHub Desktop.
Save sgibbes/1d1fa58f2d93ebeb4a40161ec01cfff1 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