I show a simple example today of using gdal tools to change from raster to polygons with Bash. That’s right. Still no pythonista here. I have poked ever so gently at the surface of ruby and rails recently, while watching another coder re-tune his brain to a new set of principles of least surprise.
By the way, for my regular readers, please be patient with me over the next few quarters. I am endeavoring to undertake a much larger writing project for the next few months, which will leave little time for this blog. But, hopefully at the end, it will be worth everyone’s while.
#!/bin/bash for name in $( ls ????_???_gt.tif); do basename1=`echo $name | awk -F'.' '{print $1}'` # Split off non-extension portion of name if [ -f $basename1".shp" ] then echo $basename1".shp exists" else echo "Converting " $basename1".shp" gdal_polygonize.py $name -f "ESRI Shapefile" $basename1".shp" if [ $? -lt 1 ] then echo "Conversion a success." echo "Removing original file." rm $name else echo "mehmeh. try again." fi fi done