Created
November 2, 2012 01:11
-
-
Save hrwgc/3998011 to your computer and use it in GitHub Desktop.
gdal trace raster outlines
This file contains 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
## run in a directory with many raster images containing nodata values that make their gdalinfo extents unreliable. output is a csv containing filename and data-containing extents, to be imported into postgis, sqlite, etc for running spatial queries. | |
## usage: | |
echo "file;GEOMETRY" > index.csv | |
declare -a FILES=$(ls -1 *tif); | |
for FILE in ${FILES[@]}; do | |
FILE=${FILE%.tif} | |
echo "$FILE.tif;" > $FILE.txt | |
gdal_trace_outline $FILE.tif -ndv '0 0' -out-cs en -wkt-out $FILE.wkt | |
cat $FILE.wkt >> $FILE.txt | |
cat $FILE.txt >> img_geoms.csv | |
rm $FILE.wkt $FILE.txt | |
done | |
cat img_geoms.csv | perl -i -pe 's~;\n~;~smg' >> index.csv | |
rm img_geoms.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment