[gdal-dev] VRT dataset to text in-memory?

Mateusz Loskot mateusz at loskot.net
Thu Mar 3 10:33:40 PST 2022


On Thu, 3 Mar 2022 at 11:16, Michael Sumner <mdsumner at gmail.com> wrote:
>
> Hello, reading the raster VRT tutorial
>
> https://gdal.org/drivers/raster/vrt.html#creation-of-vrt-datasets
>
> with this code:
>
> //
> int   nBand;
> GDALDriver *poDriver = (GDALDriver *) GDALGetDriverByName( "VRT" );
> GDALDataset *poSrcDS, *poVRTDS;
> poSrcDS = (GDALDataset *) GDALOpenShared( pszSourceFilename, GA_ReadOnly );
> poVRTDS = poDriver->CreateCopy( "", poSrcDS, FALSE, NULL, NULL, NULL );
> //
>
> Is there a way to obtained the VRT XML text representing poVRTDS without writing to an actual file?

Check what the https://gdal.org/programs/gdalbuildvrt.html does:
https://github.com/OSGeo/gdal/blob/master/apps/gdalbuildvrt_bin.cpp#L192-L196
which is this call
https://github.com/OSGeo/gdal/blob/master/apps/gdalbuildvrt_lib.cpp#L1691
which uses this builder class
https://github.com/OSGeo/gdal/blob/master/apps/gdalbuildvrt_lib.cpp#L1769
which is/can be built as a library and linked against.

Best regards,
-- 
Mateusz Loskot, http://mateusz.loskot.net


More information about the gdal-dev mailing list