I am using QGIS Madeira 3.4.3.
I am downsampling 100m TIFFs to 1000m. I am using Export - Save As GeoTIFF specifying cellsize 1000m, and the appropriate No Data value. This works just fine with the first four files. The output is a GeoTIFF with pixel size 1000, -1000.
However, I have another folder of 100m TIFFs and exporting them produces GeoTIFFs with pixel size 999.404,-999.667
All of the TIFFs are in the same Albers Equal Area projection on the NAD 83 datum. There is some variation in their origin points and extents.
Saving as a GeoPackage rather than a TIFF produces exactly the same discrepancy.
A discrepancy of half a metre in a thousand does not sound large, but with 800 cells spanning the coast it adds up to 400m difference. Besides, the point of the exercise is to get a broad selection of raters to align precisely in advance of analysis.
Has anyone seen this sort of discrepancy before?
Solutions?
Work arounds?
I looked at the Python code and the batch file. Then decided to try out GDAL_Translate in a quick and dirty batch file constructed using TextPad block editing.
:: Downsample 100m TIFFs to 1000m GeoTIFFs C:\OSGeo4W64\bin\GDAL_Translate -of GTIFF -tr 1000 1000 -r average bathy.tif bathy_1000m.tif C:\OSGeo4W64\bin\GDAL_Translate -of GTIFF -tr 1000 1000 -r average rugosity.tif rugosity_1000m.tif . . .
GDAL_Translate worked great even without a delay between batch commands. Luckily translate was fast and the TIFFs not overly large.
No issues with discrepancies in cell sizes.
I wonder if that had something to do with running outside of QGIS project?
A question for another day.
Stepping past the issue of cell size, what I really needed to do is resample some 100m rasters to 1000m and align them with a set of 1000m rasters. It would be better to carry that out in one command rather than downsampling and then realigning with possibly another round of resampling -- not the best approach.
I originally carried this out in QGIS with the Align Rasters tool. But, I had trouble with edge effects. Align rasters is supposed to ignore NoData cells, but that only seemed to apply to the reference 1000m cells while NoData values from the 100m cells were treated as legitimate values and averaged in during resampling.
What I am looking for is a GDAL command that will allow me to downsample and realign in one go all while observing NoData values and preserving the specification of NoData value in the output.
I have looked at GDALWarp but am not looking to warp the rasters. They are all already in the same Albers Equal Area projection on the NAD83 datum. I would prefer not to have to try to choose parameters to strangle GDALWarps tendency to warp.
Is there another GDAL command I should be looking at?