I have two sets of TIFFs of different resolutions (100m and 1000m), different alignment, and varying data types with corresponding no data values. I need to downsample the 100m TIFFs to match the resolution and alignment of the 1000m TIFFs. I also need to preserve no data values in each TIFF.
I am having a heck of a time accomplishing all three objectives in a straight forward manner without using multiple tools with repetitive resampling degrading the information. Ideally, I would like to be able to accomplish all three objectives from the command line via batch, stand alone Python, or the Python window.
I have been able to achieve the correct cell size, no data value, and alignment, but by using awkward combinations of
From inside QGIS and from a batch file running c:\OSGeo4W64\bin\GDAL_Translate.exe;
- Align Rasters
Only from inside QGIS where the menu does not allow the specification of no data values for both the source and reference TIFFs leading to edge-effects as 100m TIFF no data values are included in averaging during resampling. Will work only if 100m raster has already been resampled to 1000m and is then resampled again by Align Rasters. I have not been able to run Align Rasters from any sort of command line in batch or Python. I have not even found Align Rasters on my computer as Python nor as executable.
Documentation seems to suggest that I could use GDALWarp specifying Target Aligned Pixels (-tap) to accomplish all three in one go. I can run c:\OSGeo4W64\bin\gdalwarp.exe from a simple batch file, but the -tap parameter is ineffective at aligning the result.
What I have tried is,
C:\OSGeo4W64\bin\GDALWarp -tr 1000 -1000 -tap ..\ROMS\BottomSalinity_max.tif -r average -srcnodata -32768 -dstnodata -32768 -of GTiff -overwrite bathy.tif bath_1000m_ROMS.tif
Can anyone see what I would need to change here?
I have to confess I am not sure I properly understand the single sentence in the documentation describing the purpose of the -tap parameter.
"-tap: (GDAL >= 1.8.0) (target aligned pixels) align the coordinates of the extent of the output file to the values of the -tr, such that the aligned extent includes the minimum extent."
Other threads (and I have read a lot of them recently) suggest that -tap is the way to align rasters. Am I just failing to supply the correct parameters or, is -tap not the way to align rastes?
Is there a way to access Align Rasters from the command line avoiding gdalwarp? I do not need to warp -- just downsample and align. I am only looking at gdalwarp as a tool through which I can successfully set the parameters for downsampling and aligning.