[gdal-dev] Error in gdalwarp

Paolo Cavallini cavallini at faunalia.it
Sat Oct 22 23:06:32 PDT 2016


Hi Even,

Il 22/10/2016 21:54, Even Rouault ha scritto:

> Since GDAL 2.1, validation of the cutline geometry once reprojected into 
> source coordinates is done, and defaults into an error if the validation 
> fails.
> 
> Here the issue is linked to the fact that when the cutline datasource is made 
> of several polygons, a multipolygon is made with them by adding them as parts 
> of the multipolygon. And if you do that on watersheds.shp, it results in a 
> invalid multipolygon likely because the parts share common boundaries

Thanks for the detailed explanation.

> You can revert to the previous behaviour and avoid the error to be fatal by 
> adding
> --config GDALWARP_IGNORE_BAD_CUTLINE YES
> to the gdalwarp command line.
> 
> The clipping to the cutline might work or not depending on the nature of the 
> invalidity (in your case that shouldn't be an issue). The check was added 
> because there were use cases where unnoticed invalidities resulted in rather 
> critical issues (for example when you need to clip out some regions because of 
> regulations on forbidden zones, and an invalidity causes an area that should 
> have been clipped out to not being clipped out).

Rather tricky. The same analysis seems to run fine, however, on the same
data with different software.
What would be your advice for gdalwarp usage in QGIS>Processing? Just
adding GDALWARP_IGNORE_BAD_CUTLINE YES by default, and perhaps an extra
option to disable it?

> Probably that in the use case you point, the way the multipolygon is built 
> should be revised to use a proper unioning operation instead of the current 
> rather naive way. Could be worth a ticket.
> 
> You can do that step manually with:
> 
> ogr2ogr cutline.shp -sql "select st_union(geometry) from watersheds" 
> watersheds.shp -dialect sqlite

Unfortunately this removes all internal borders, making it unusable for
the original purpose.
All the best.

-- 
Paolo Cavallini - www.faunalia.eu
QGIS & PostGIS courses: http://www.faunalia.eu/training.html
https://www.google.com/trends/explore?date=all&geo=IT&q=qgis,arcgis


More information about the gdal-dev mailing list