Created
December 6, 2016 12:01
-
-
Save stiles/596f0b8419173cfc337a082753e6a45b to your computer and use it in GitHub Desktop.
Merge multiple shapefiles (year to year, for example) and append attribute table to include original file name (for categorization)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for f in *.shp | |
do | |
base=${f%.shp} | |
ogrinfo $f -sql "ALTER TABLE $base ADD COLUMN filename character(15)" | |
ogrinfo $f -dialect SQLite -sql "UPDATE $base SET filename = '$base'" | |
ogr2ogr -update -append merged.shp $f | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment