I'm hoping someone can shed some light on the use of gdalwarp for me. I'm trying to use it to effectively trim an mosaicked image of its sawtooth edges by masking the area outside a line as defined by a shapefile. I've been successful when using a single polygon such as with this command here:
Where 1642.shp is located in the .\shp directory. 1642.shp is a single polygon record extracted from a larger multi-record shape file know as 'allROIS.shp' also located at .\shp and contains a field named 'item'.
The problem is that I have a whole mess of these things that i need to trim. So I was trying to use the -csql switch to reference the particular record within 'allROIs.shp' but I'm not having much luck. The command i'm issuing is:
gdalwarp -cutline .\shp -csql "select * from allROIs where item = 1642" -crop_to_cutline .\1642.bmp .\cutlinetest.tif
The error I'm receiving is:
Cannot compute bounding box of cutline.
The individual polygons within allROIs.shp overlap but are separate records. Not sure if that's significant.
Any insight is appreciated. Thanks.
I have also tried using the -cwhere switch in gdalwarp without luck. I have however been able to use ogr2ogr to extract the individual polygons using ITS -where switch specifying
-where "Item = 1642"
I had hoped that the syntax would be the same in gdalwarp. But using
seems to fail to compute cutline bounding box when there is a .prj file present for the .shp and the target image has no georeference embeded as with a geotiff. Here in this case I was trying to trim a .bmp so that was that I think was the reason.
However remove the .prj from the .\shp directory and it works! Alternatively, I can specify the -s_srs and -t_srs as the same and this also works although it does throw a warning that the input vector layer has an srs while the raster does not. As long as the two are in the same projection. No problem I think.