Would an in-memory /vsi also work as an intermediate?

Expressed as windows CMD batch file I have handy:

gdalwarp -of vrt –t_srs epsg:3578 %1 /vsistdout | gdal_translate /vsistdin/ %2


-Matt

From: gdal-dev <gdal-dev-boun...@lists.osgeo.org> On Behalf Of Even Rouault
Sent: January 19, 2022 9:00 AM
To: Billy Babis <billyba...@gmail.com>; gdal-dev@lists.osgeo.org
Subject: Re: [gdal-dev] Potential bug or misunderstanding. Please help


Billy,

bandList is currently ignored in the separate=True case. This would be a 
reasonable enhancement request that you could file on 
https://github.com/OSGeo/gdal/issues/new<https://imsva91-ctp.trendmicro.com:443/wis/clicktime/v1/query?url=https%3a%2f%2fgithub.com%2fOSGeo%2fgdal%2fissues%2fnew&umid=8E1E185C-D5F1-7B05-A573-C40D9183224D&auth=c132af8ee7c9d1278d61a701569070a095ce962e-963983d70993dd628f3a829c6da1de9b915a8a43>

One of the workaround for now is to postedit the generate VRT file and 
substitute the <SourceBand>1</SourceBand> element with 
<SourceBand>2</SourceBand>

You could also use use gdal.Translate() to produce a VRT with the second band 
of each source file, and run gdal.BuildVRT() on those files, but that would 
produce temporary files. If you don't need to serialize the output_vrt_fname, 
but use the returned dataset object with other APIs in the same process, you 
could avoid actual file creation by using an empty name for those intermediate 
VRT files, get the returned dataset object, and pass an array with those 
dataset objects instead of lst_of_input_geotiff_files.

Even

Le 19/01/2022 à 16:51, Billy Babis a écrit :
Hi there.

Given 3 input geotiffs (each with 2 bands), I want to create 1 geotiff with 3 
bands (the 2nd band from each aforementioned geotiff). This should be quite 
simple using gdal.BuildVRT and gdal.translate. But, gdal.BuildVRT will not 
allow me to select the 2nd band from each input image. The following code 
produces the following warning:

Code:
gdal.BuildVRT(output_vrt_fname, lst_of_input_geotiff_files, separate=True, 
bandList=[2])

Warning:
 "fname.tif has 2 bands. Only the first one will be taken into account for the 
-separate case"

Of course, I do not want to only use the first band, I want to use the 2nd band 
to create the VRT. Please let me know what I'm doing wrong and how I can fix it.

Best,
Billy B

--
Billy Babis
PhD Candidate: Environmental Economics & Policy (ABD)
Computer Science B.S.
1-(908)-403-2006




_______________________________________________

gdal-dev mailing list

gdal-dev@lists.osgeo.org<mailto:gdal-dev@lists.osgeo.org>

https://lists.osgeo.org/mailman/listinfo/gdal-dev

--

http://www.spatialys.com<https://imsva91-ctp.trendmicro.com:443/wis/clicktime/v1/query?url=http%3a%2f%2fwww.spatialys.com&umid=8E1E185C-D5F1-7B05-A573-C40D9183224D&auth=c132af8ee7c9d1278d61a701569070a095ce962e-922e18d95be76772930fc905d0f7d174629efcdc>

My software is free, but my time generally not.
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to