[gdal-dev] Order of operations in GDALWARP

Abdul Raheem Siddiqui abdulraheemsiddiqui at gmail.com
Tue May 10 15:47:20 PDT 2022


Hello all,

I would like to know if anyone in the community is aware of a way to
control GDALWARP order of operations, or is it even possible?

I need GDAL to reproject a raster to a new CRS and cell size then mask the
raster to a polygon.

(the new size is smaller than the original, I know it is not a great idea,
but we need to do it for our purposes)

Here is the command

gdalwarp -overwrite -t_srs EPSG:26917 -of GTiff -cutline
C:/Users/asiddiqui/Downloads/MASK.gpkg -cl MASK -tr 30.0 30.0 -te
527130.3170769732 3656970.1048127464 571830.3170769732
3707430.1048127464 -r near -wo CUTLINE_ALL_TOUCHED=TRUE
C:/Users/asiddiqui/Downloads/Align_Test_data/Precip.tif
C:/Users/asiddiqui/Downloads/Precip2.tif

GDAL is masking the raster first, thus picking cells with larger sizes that
are touching polygon and then reprojecting and making cell size smaller.
This is causing a lot of extra cells to be there when they shouldn't be
(Hard to visualize here because the actual raster cell size is smaller than
the size that appears in the picture because all the small cells have the
same value). [image: enter image description here]
<https://i.stack.imgur.com/SI4Qc.png>

What I want GDAL to do is to reproject the raster to a smaller cell size
first and then mask to get a result like this.

[image: enter image description here] <https://i.stack.imgur.com/O3mbc.png>

Abdul Raheem Siddiqui
abdulraheemsiddiqui at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20220510/562016d9/attachment-0001.htm>


More information about the gdal-dev mailing list