Reprocessing imagery with GDAL and BASH — and then cleaning up afterward

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.


for name in $( ls ????_???_gt.tif);

basename1=`echo $name | awk -F'.' '{print $1}'`              # Split off non-extension portion of name

if [ -f $basename1".shp" ]
echo $basename1".shp exists"
echo "Converting " $basename1".shp" $name -f "ESRI Shapefile" $basename1".shp"

if [ $? -lt 1 ]
echo "Conversion a success."
echo "Removing original file."
rm $name
echo "mehmeh.  try again."



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.