2

I am struggling to use gdalwarp with cutline option. The following command keeps failing and I do not understand why :

gdalwarp  -cutline shapefile.shp  file.tiff newfile.tiff

Warning 1: Self-intersection at or near point 1890.1578688362522 >211.13062073074084

ERROR 1: Cutline is not valid after transformation

The produced file is indeed not valid being filled with NA ... I tried with several shapefiles and tiff files but I could not make it works.

I use debian and gdal version 2.1.0

  • I have used the following which worked for me: gdalwarp -cutline shapefile.shp -crop_to_cutline file.tif newfile.tif. If this doesn't help then hopefully others can advise :) – Joseph Jun 9 '16 at 10:51
  • Error "Cutline is not valid after transformation" makes me think that your shapefile in not in the same projection than your image, and something goes wrong when the geometry is re-projected into the SRS of your image. – user30184 Jun 9 '16 at 10:56
  • To joseph: Thx for your help. However it doesn't solve my pb – user3507085 Jun 9 '16 at 10:57
  • To user30184: Let me check that – user3507085 Jun 9 '16 at 10:59
  • 1
    Error message may mean that some coordinate has a value 1890.1578688362522 which can't be EPSG:4326. – user30184 Jun 9 '16 at 19:49
4

Try adding the option

--config GDALWARP_IGNORE_BAD_CUTLINE YES

to gdalwarp, like this:

gdalwarp --config GDALWARP_IGNORE_BAD_CUTLINE YES -cutline shapefile.shp file.tiff newfile.tiff

0

It had to do with the geometry of my shape-file. I splitted the single features to identify the polygons which created a problem. There was no real validity conflict detected and could not be seen as well, but I left a bit space between two adjacent polygons and then it worked.

  • The answer is posted as if you were the originator of the question, is that the case? If so you should look to merge your accounts, – nmtoken Sep 21 '16 at 13:54
-1

I have seen the same problem.

In my case the raster and the clip vector are both in the same space so there is no need for a transformation.

It worked with earlier versions of GDAL so I suggest regressing to 2.02 and it will work.

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.