How to ‘invert’ or ‘reverse’ a vector cutline when gdalwarp'ing a raster?

المشرف العام

Administrator
طاقم الإدارة
I have a raster of North America and I'd like to remove the larger lakes from it, replacing them with the same no-data value as the original raster.

So I downloaded Natural Earth's 10 meter lakes vector data, which has lakes conveniently ranked by scale rank: 0 for large lakes like the Great Lakes, and larger scale ranks for more minor lakes.

The closest I've come with gdalwarp is:

$ gdalwarp -cutline Data/ne_10m_lakes/ne_10m_lakes.shp \ -csql "SELECT * FROM ne_10m_lakes WHERE scalerank=0" \ INPUT.tif lakes-only.tifThis actually does the opposite of what I want, it keeps only the Great Lakes portions of my raster, replacing all other non-lake pixels with the no-data value.

My question: how can I invert the cutline, so instead of getting the area inside the lake boundary, I get whatever is outside it? Can I invert the original Natural Earth .shp file, perhaps?

References

In How to invert polygons (or other options for exterior styling)?, GRASS' r.mask was suggested, which has an inverse mode. Is there something similar with OGR/GDAL?

In How to get an ocean shapefile from a very detailed land area shapefile?, the .shp file was converted to a raster, then inverted, and used as a mask. I'd prefer not to generate a raster of non-lakes because my original TIFF raster is very large (high resolution) and I'd prefer not to generate a raster of the same size.



أكثر...
 
أعلى