<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Billy,</p>
<p>bandList is currently ignored in the separate=True case. This
would be a reasonable enhancement request that you could file on
<a class="moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/issues/new">https://github.com/OSGeo/gdal/issues/new</a></p>
<p>One of the workaround for now is to postedit the generate VRT
file and substitute the <SourceBand>1</SourceBand>
element with <SourceBand>2</SourceBand></p>
<p>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.</p>
<p>Even<br>
</p>
<p>Le 19/01/2022 à 16:51, Billy Babis a écrit :<br>
</p>
<blockquote type="cite"
cite="mid:CAPiO2JYVo-Zqh107MHYGR_qRtr1=Q0zd0f=3rjr_DR9Goj1q_w@mail.gmail.com">
<div dir="ltr">
<div>Hi there.</div>
<div><br>
</div>
<div>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:</div>
<div><br>
</div>
<div><b>Code:</b><br>
gdal.BuildVRT(output_vrt_fname, lst_of_input_geotiff_files,
separate=True, bandList=[2])</div>
<div><br>
</div>
<div><b>Warning:</b></div>
<div> "fname.tif has 2 bands. Only the first one will be taken
into account for the -separate case"</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>Best,</div>
<div>Billy B</div>
<div><br>
</div>
-- <br>
<div dir="ltr" class="gmail_signature"
data-smartmail="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>Billy Babis</div>
<div>PhD Candidate: Environmental Economics &
Policy (ABD)</div>
<div>Computer Science B.S.</div>
<div>1-(908)-403-2006</div>
<div><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</body>
</html>