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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Scott Staniewicz
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?


_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Combining raw .vrt with derived bands

Even Rouault-2
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
_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|

Re: Combining raw .vrt with derived bands

Scott Staniewicz
Oh very cool, thanks!
So that appears to work for getting the Derived band (pasted below), but I've got 2 followups

1. is there any way to access the nested VRT? So for this one .vrt, it would have one band as Float32 (the derived phase), and one as CFloat32 (the original raw file). Or are the different datatypes not allowed as different bands in one raster?
2. If I wanted to have two derived bands (say, a logamp derived band), would I need to copy the CDATA section twice?

Thanks (apologies for the mis-reply the first time)


(This loaded correctly, but only has 1 band)

<VRTDataset rasterXSize="720" rasterYSize="720">
  <SRS>...</SRS>
  <GeoTransform>  ...</GeoTransform>
  <VRTRasterBand dataType="Float32" band="1" subClass="VRTDerivedRasterBand">
    <SimpleSource>
      <SourceFilename><![CDATA[
        <VRTDataset rasterXSize="720" rasterYSize="720">
          <SRS>...</SRS>
          <GeoTransform>  ...</GeoTransform>
          <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>
        </VRTDataset>
      ]]></SourceFilename>
      <SourceBand>1</SourceBand>
      <SourceProperties RasterXSize="720" RasterYSize="720" DataType="CFloat32" BlockXSize="720" BlockYSize="1" />
    </SimpleSource>
    <PixelFunctionType>phase</PixelFunctionType>
    <SourceTransferType>CFloat32</SourceTransferType>
  </VRTRasterBand>
</VRTDataset>


On Wed, Mar 11, 2020 at 9:54 AM Even Rouault <[hidden email]> wrote:
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

_______________________________________________
gdal-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/gdal-dev