[Gdal-dev] vrt format and absolute/relative paths

Frank Warmerdam warmerdam at pobox.com
Tue Mar 16 13:39:10 EST 2004


Vincent Schut wrote:
>>Is this behaviour intended?
>>If not, if would greatly help me if it could be changed so that gdal always
>>uses the home directory of the current vrt file to look for the vrt raster
>>source files.

Vincent,

I have modified the VRT code in CVS so that it will check for a relativeToVRT
attribute on the SourceFilename element.  If it is set to a non-zero value then
the SourceFilename will be treated relative to the virtual file.   For example:

<VRTDataset rasterXSize="512" rasterYSize="512">
   <VRTRasterBand dataType="Byte" band="1">
     <ColorInterp>Gray</ColorInterp>
     <SimpleSource>
       <SourceFilename relativeToVRT="1">utm.tif</SourceFilename>
       <SourceBand>1</SourceBand>
       <SrcRect xOff="0" yOff="0" xSize="512" ySize="512"/>
       <DstRect xOff="0" yOff="0" xSize="512" ySize="512"/>
     </SimpleSource>
   </VRTRasterBand>
</VRTDataset>

Currently CreateCopy() does not attempt to set this, and relativize the path
though it might at some point in the future.

In general, even when doing a gdal_translate the .vrt may be put somewhere
completely unrelated to the actual files in which case it is hard to make
the SourceFilename relative to the .vrt.  While it has some significant
problems the code (for the time being) will just literally place whatever
filename you give it for the the input file into the SourceFilename element.

However, with a minor hand edit to your .vrt files you should now be able to
use them as desired.

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