[Gdal-dev] Creating VRT datasets
Frank Warmerdam
warmerdam at pobox.com
Fri Sep 8 23:01:23 EDT 2006
On 9/8/06, Frank Warmerdam <warmerdam at pobox.com> wrote:
> On 9/8/06, Matt Hanson <mhanson at photon.com> wrote:
> > I'm having problems programatically creating VRT datasets.
> >
>
> Matt,
>
> This is a bug in the VRT "create from metadata" logic.
> It works for calls via SetMetadata(), but not via
> SetMetadataItem(). I found that the following slight
> variation does work.
Matt,
As usual, I forgot the actual text.
#include "gdal_priv.h"
int main()
{
GDALAllRegister();
GDALDriver *driver = (GDALDriver *) GDALGetDriverByName( "VRT" );
GDALDataset *ds = driver->Create("test.vrt", 500, 500, 1, GDT_Byte, NULL );
char *pszXML = "source_0=<SimpleSource>"
"<SourceFilename relativeToVRT=\"1\">utm.tif</SourceFilename>"
"<SourceBand>1</SourceBand>"
"<SrcRect xOff=\"0\" yOff=\"0\" xSize=\"100\" ySize=\"100\"/>"
"<DstRect xOff=\"0\" yOff=\"0\" xSize=\"100\" ySize=\"100\"/>"
"</SimpleSource>";
char *apszMD[2] = { pszXML, NULL };
// ds->GetRasterBand(1)->SetMetadataItem("source_0", pszXML,
"new_vrt_sources");
ds->GetRasterBand(1)->SetMetadata( apszMD, "new_vrt_sources");
delete ds;
}
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | Geospatial Programmer for Rent
More information about the Gdal-dev
mailing list