[Gdal-dev] Creating VRT datasets

Matt Hanson mhanson at photon.com
Fri Sep 8 15:40:49 EDT 2006


I'm having problems programatically creating VRT datasets.
 
Here's my code:
 
GDALDataset *ds = driver->Create(filename, ROI.width(), ROI.height(), 1, GDALType(&typeid(T)), NULL);
stringstream XML;
XML << "<SimpleSource>"
<< "<SourceFilename relativeToVRT=\"1\">" << Image.Filename() 
<< "</SourceFilename><SourceBand>1</SourceBand>"
<< "<SrcRect xOff=\"" << ROI.x0() << "\" yOff=\"" << ROI.y0() << "\" xSize=\"" << ROI.width()
<< "\" ySize=\"" << ROI.height() << "\"/>"
<< "<DstRect xOff=\"0\" yOff=\"0\" xSize=\"" << ROI.width() << "\" ySize=\"" << ROI.height() << "\"/>"
<< "</SimpleSource>";
ds->GetRasterBand(1)->SetMetadataItem("source_0", XML.str().c_str(), "new_vrt_sources");
delete ds;
 
**************************************************
 
What I get for an output file is:
<VRTDataset rasterXSize="400" rasterYSize="400">

<VRTRasterBand dataType="Int16" band="1"/>

</VRTDataset>

**************************************************

It's not writing the SimpleSource section using the SetMetaDataItem function.   Am I using it wrong here?





More information about the Gdal-dev mailing list