[gdal-dev] Combining raw .vrt with derived bands

Even Rouault even.rouault at spatialys.com
Wed Mar 11 07:54:32 PDT 2020


On mercredi 11 mars 2020 09:49:49 CET Scott Staniewicz wrote:
> Is it possible to have a VRTRawRasterBand and a VRTDerivedRasterBand, which
> is derived from that Raw file, together as two bands in a single VRT file?
> 
> 
> I've got a CFloat32 raster file with only one complex band in binary format
> (called "20160327_20160420.int" in the example below), and I've figured out
> how to make a VRT for it so I can load it with GDAL.
> 
> "20160327_20160420.int.vrt":
> 
> <VRTDataset rasterXSize="720" rasterYSize="720">
>   <VRTRasterBand dataType="CFloat32" band="1" subClass="VRTRawRasterBand">
>     <SourceFilename relativeToVRT="1">20160327_20160420.int</SourceFilename>
> <ImageOffset>8</ImageOffset>
>     <PixelOffset>8</PixelOffset>
>     <LineOffset>5760</LineOffset>
>     <ByteOrder>LSB</ByteOrder>
>   </VRTRasterBand>
>   <SRS>WGS84</SRS>
>   <GeoTransform> ...</GeoTransform>
> </VRTDataset>
> 
> This works great. I've also figured out how to make a derived raster band
> from this that shows the amplitude of the data, and also the phase (below):
> 
> "20160327_20160420.int.phase.vrt":
> 
> <VRTDataset rasterXSize="720" rasterYSize="720">
>   <SRS>...</SRS>
>   <GeoTransform>  ...</GeoTransform>
>   <VRTRasterBand dataType="Float32" band="1"
> subClass="VRTDerivedRasterBand">
>     <Description>phase of 20160327_20160420.int.vrt </Description>
>     <SimpleSource>
>       <SourceFilename
> relativeToVRT="1">20160327_20160420.int.vrt</SourceFilename>
>       <SourceBand>1</SourceBand>
>       <SourceProperties RasterXSize="720" RasterYSize="720"
> DataType="CFloat32" BlockXSize="720" BlockYSize="1" />
>     </SimpleSource>
>     <PixelFunctionType>phase</PixelFunctionType>
>     <SourceTransferType>CFloat32</SourceTransferType>
>   </VRTRasterBand>
> </VRTDataset>
> 
> But I can't figure out how I would get both of these as two bands in one
> VRT without causing an infinite recursion. Is that possible? Or do I need
> to keep them separate?

In the top level VRT, instead of having

<SourceFilename relativeToVRT="1">20160327_20160420.int.vrt</SourceFilename>

you can put the content of .int.vrt inline in a CDATA section

<SourceFilename relativeToVRT="1"><![CDATA[put here content of 
20160327_20160420.int.vrt]]></SourceFilename>

See example from autotest suite:
https://github.com/OSGeo/gdal/blob/master/autotest/gcore/data/vrtinvrt.vrt

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list