I am trying to use the python script from http://www.sparkgeo.com/labs/2010/07/07/gdal-clipping-hack/ to clip a raster based on many shapefiles. The script is using a mysql database an i would like to use it on a directory of shapefiles. I am not a programmer so I'am not sure how to make this work.
Then you can pick up with the rest of the script in that post, putting it into the ...
Not knowing 100% what you want to do keep in mind the QGIS GDALTools - Clipper will show you how to build a gdalwarp command to do something similar.
Wow! That's an incredibly inefficient way of clipping a raster. OGR/GDAL can be used straight from the command line without recourse to Python in this case.
First, you need to merge your shapefiles into one big one. Assuming you're using Windows, the following DOS batch file is taken from here (a UNIX/Linux script will be syntactically different, but will follow the same form):
This generates a shapefile called
Then you can clip your raster based on this shapefile quite simply using gdalwarp like this: