[gdal-dev] Re: How would run the geographic query against the shape file via a gdal command line program?

Hermann Peifer peifer at gmx.eu
Sat Aug 8 11:47:17 EDT 2009


John Mitchell wrote:
> I have tried running both gdalwarp and gdal_merge against a subset of
> hundreds of geotiff images via geographic bounding box.
> I would like to speed up the performance by running a geographic query
> against the shape file which was already created via gdaltindex against all
> the geotiff images.
> Next I would like to take the selected objects from the shapefile and use
> the location field to derive all geotiffs which are then used to as source
> to run against gdal_merge or gdalwarp.
> 
> How would run the geographic query against the shape file via a gdal command
> line program?
> 

You could use:

ogrinfo -spat xmin ymin xmax ymax

man ogrinfo says about the spat argument:
> The area of interest. Only features within the rectangle will be reported. 


A hack, rather than a solution could be in your case:

TIFF_LIST=$(ogrinfo -ro -al -geom=NO -spat xmin ymin xmax ymax your_index.shp |
awk '/location.*=/{list = list " " $NF}END{print list}')

... followed by:

gdalwarp $TIFF_LIST outfile.tif

The above assumes geotiff file names without spaces. There must be smarter solutions, perhaps by constructing a cutline for galwarp.

Hermann



More information about the gdal-dev mailing list