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

2022-03-06 Thread Michael Sumner
Excellent, Even - thanks so much, I have this working now.  I've crafted a
PR for the example.

Mateusz: thank you for the source code overview, I will be using that too.

Best, Mike

On Sun, Mar 6, 2022 at 10:18 PM Even Rouault 
wrote:

> Michael,
>
> yes you can get the VRT XML text with:
>
> poVRTDS->GetMetadata("xml:VRT")[0]
>
> If you can submit a pull request documenting that, that would be welcome
>
> Even
> Le 03/03/2022 à 11:14, Michael Sumner a écrit :
>
> 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?
>
> Sorry if this is obvious, haven't been able to find an example that does
> what I want. I've seen examples using GetMetadataItem from a band for parts
> of the XML, but can't see how to get the entire thing.
>
> Thanks for your help.
>
> Best, Mike
>
>
> --
> Michael Sumner
> Software and Database Engineer
> Australian Antarctic Division
> Hobart, Australia
> e-mail: mdsum...@gmail.com
>
> ___
> gdal-dev mailing 
> listgdal-dev@lists.osgeo.orghttps://lists.osgeo.org/mailman/listinfo/gdal-dev
>
> -- http://www.spatialys.com
> My software is free, but my time generally not.
>
>

-- 
Michael Sumner
Software and Database Engineer
Australian Antarctic Division
Hobart, Australia
e-mail: mdsum...@gmail.com
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev


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

2022-03-06 Thread Even Rouault

Michael,

yes you can get the VRT XML text with:

poVRTDS->GetMetadata("xml:VRT")[0]

If you can submit a pull request documenting that, that would be welcome

Even

Le 03/03/2022 à 11:14, Michael Sumner a écrit :

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?


Sorry if this is obvious, haven't been able to find an example that 
does what I want. I've seen examples using GetMetadataItem from a band 
for parts of the XML, but can't see how to get the entire thing.


Thanks for your help.

Best, Mike


--
Michael Sumner
Software and Database Engineer
Australian Antarctic Division
Hobart, Australia
e-mail: mdsum...@gmail.com

___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev


--
http://www.spatialys.com
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


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

2022-03-03 Thread Mateusz Loskot
On Thu, 3 Mar 2022 at 11:16, Michael Sumner  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
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev


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

2022-03-03 Thread Michael Sumner
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?

Sorry if this is obvious, haven't been able to find an example that does
what I want. I've seen examples using GetMetadataItem from a band for parts
of the XML, but can't see how to get the entire thing.

Thanks for your help.

Best, Mike


-- 
Michael Sumner
Software and Database Engineer
Australian Antarctic Division
Hobart, Australia
e-mail: mdsum...@gmail.com
___
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev