I am using gdalwarp to reproject a greyscale GeoTiff tile from one projection to another so I can use it in a VRT. This is required as gdalbuildvrt won't accept files in multiple projections.
When I run gdalbuildvrt, I'm getting the error:
Warning 1: gdalbuildvrt does not support heterogeneous band numbers: expected 1, got 2. Skipping <filename>
If I run gdalinfo on the source image, it shows me the following band info:
Band 1 Block=1000x2 Type=Float32, ColorInterp=Gray
Min=442.516 Max=590.010
Minimum=442.516, Maximum=590.010, Mean=493.853, StdDev=19.508
NoData Value=-9999
Running gdalinfo on the destination image shows the following band info:
Band 1 Block=1055x1 Type=Float32, ColorInterp=Gray
Band 2 Block=1055x1 Type=Float32, ColorInterp=Alpha
However, I don't seem to be able to come up with options for gdalwarp so that it creates an output image with just the gray band, and no alpha band. The output file should have 1 band and a NoData value of -9999, just like the input file.
gdalwarp command lines I have tried include:
gdalwarp -t_srs EPSG:28356 -r cubic <srcFile> <destFile>
gdalwarp -t_srs EPSG:28356 -r cubic -dstalpha <srcFile> <destFile>
gdalwarp -t_srs EPSG:28356 -r cubic -srcnodata -9999 -dstnodata -9999 <srcFile> <destFile>
How to avoid gdalwarp converting to alpha band appears to be asking a similar question, but the one answer given appears to be essentially the same as my last command line above, which does not work.
Is there a way of converting a single-band greyscale GeoTiff from one projection to another without creating an alpha channel?
Sample input TIF file can be found at https://ozultimate.com/downloads/srcfile.tif. I am reprojecting from EPSG:28355 to EPSG:28356
gdalwarp -t_srs EPSG:28356 -r cubic srcfile.tif dstfile.tifand did not get an alpha band. You could try -b band https://gdal.org/programs/gdalwarp.html – user2856 Jul 12 '23 at 04:41-overwriteoption. So you are correct thatgdalwarp -t_srs EPSG:28356 -r cubic srcfile.tif dstfile.tifseems to work. – Tom Brennan Jul 12 '23 at 07:48