[gdal-dev] Query regarding using gdalwarp with cutlineSQL

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[gdal-dev] Query regarding using gdalwarp with cutlineSQL

Prasun Kumar Gupta
Hi,

I am trying to clip a raster using a polygon layer. I want to specify a where clause to select one polygon feature from the polygon layer and subset the raster only for that one polygon feature.

I am not getting the intended results with this line of code:

ds = gdal.Warp('output.tif', 'input.tif', format = 'GTiff', \
               cutlineDSName = 'parcel.shp', \
               cutlineSQL = 'SELECT * FROM parcel', \
               cutlineWhere = 'name = "first"')

if ds is None:
    print('Failed')
else:
    print('Success')
# prints Success but gives same result as without the cutlineSQL and cutlineWhere options
Problem is also explained in detail on StackExchange (with screenshots and sample data).
Could someone please let me know what I am missing?

Regards,
Prasun



_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Query regarding using gdalwarp with cutlineSQL

Luke
You need  single quotes around your string literal:

cutlineWhere="name = 'first'"



--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Query regarding using gdalwarp with cutlineSQL

Cainã K. Campos
I believe that you should use either the cutlineWhere or the cutlineSQL.

When I want a single field selection, I use the cutlineWhere,
when it is more complex I use the cutlineSQL

On Fri, Jul 31, 2020 at 6:40 PM Luke <[hidden email]> wrote:
You need  single quotes around your string literal:

cutlineWhere="name = 'first'"



--
Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev

_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev