I'm trying to clip a raster with a polygon layer containing multiple features. To achieve my goal I'm trying to execute those commands lines on a batch file :

cd C:\Program Files\QGIS 2.18\bin
gdalwarp   -cutline C:\poly1.shp -crop_to_cutline -of GTiff -cwhere "'id' = 
'1'"   -r bilinear    C:\western_1.tif  C:\1_dma_western.tif
gdalwarp   -cutline C:\poly1.shp -crop_to_cutline -of GTiff -cwhere "'id' = 
'2'"    -r bilinear   C:\western_1.tif  C:\2_dma_western.tif
gdalwarp   -cutline C:\poly1.shp -crop_to_cutline -of GTiff -cwhere "'id' = 
'3'"   -r bilinear    C:\western_1.tif  C:\3_dma_western.tif

unfortunately I get this Error :

ERROR 4: Unable to open EPSG support file gcs.csv.  Try setting the 
GDAL_DATA environment variable to point to the directory containing EPSG csv 
ERROR 1: Did not get any cutline features.

Both, raster and polygon layer are using the same EPSG. I'm working with gdal which is installed with qgis.

  • 1
    The environment settings are not correct in your command shell. Do you have any .bat files in the \bin directory?
    – user30184
    Oct 19, 2017 at 11:21
  • I figured out that I had some env var missing it fixed the first, but i still have this error : did not get any cutline features Oct 19, 2017 at 11:30
  • 2
    The to use -cwhere without quotes around id and the value. You can test if the selection finds anything with ogrinfo ogrinfo -where "id=1" c:\poly1.shp.
    – user30184
    Oct 19, 2017 at 11:37
  • user30184 Thank you so much it works perfecty. Oct 19, 2017 at 12:27
  • @user30184 It looks like you've helped solve the problem - can you expand on your comment a little and turn it into an answer?
    – Midavalo
    Oct 19, 2017 at 21:00

1 Answer 1


> Error 4 :

fixed it by

  • adding my missing variable (PGDATA),
  • updating the value of the variable GDAL_DATA, I found it using PostgreSQL 9.5 instead of 9.6.
  • Adding the path to the bin folder of PostgreSQL 9.6 in the Path variable.

> Error 1 :

I had to remove the quotes around the id and it's value

cd C:\Program Files\QGIS 2.18\bin
gdalwarp -cutline C:\poly1.shp -of GTiff -cwhere "id = 1" -r bilinear -
crop_to_cutline -overwrite C:\western_1.tif 
gdalwarp -cutline C:\poly1.shp -of GTiff -cwhere "id = 2" -r bilinear -
crop_to_cutline -overwrite C:\western_1.tif 
gdalwarp -cutline C:\poly1.shp -of GTiff -cwhere "id = 3" -r bilinear -
crop_to_cutline -overwrite C:\western_1.tif 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.