[gdal-dev] gdal_edit.py question
Even Rouault
even.rouault at spatialys.com
Thu Sep 12 12:21:25 PDT 2024
Scott,
>
> # add another tif to band 2 and add meta data for it:
> gdalwarp -q -srcband 1 -dstband 2 -t_srs EPSG:4326 src2.tif result.tif
BAND1 is lost at that stage. gdalwarp must override the metadata of the
output dataset with the one of src2.tif.
Presumably it should instead merge them, using the same logic as what it
does if you provide several input files in a single gdalwarp operation,
but this is also questionable if it is always desirable... The hardest
part would to name a switch to control that behavior.
A few line GDAL Python script would allow you to automate the merging of
metadata.
> Another unrelated thing, if I try to add a second band to an existing
> single band raster using gdalwarp, it throws an error saying the
> second band doesn't exist. That's understandable, hence gdal_create.
> The downside is, if you're working with an unknown number of bands,
> you can't just add it. This would be an extremely useful feature when
> working with NETCDF, HDF, etc.
A difficult one to implement. That would involve using the AddBand()
method, but very few drivers support it (GeoTIFF doesn't in particular),
mostly because of format limitations.
Another way of proceeding is to:
- use warped-vrt for the source 1-band datasets,
- use gdalbuildvrt -separate to create a multi-band VRT from those
warped VRTs,
- and gdal_translate to convert that to GeoTIFF.
Even
--
http://www.spatialys.com
My software is free, but my time generally not.
More information about the gdal-dev
mailing list