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

Vincent Schut schut at sarvision.com
Tue Mar 16 04:01:38 EST 2004


Adding to myself:

note that also gdal_translate creates vrt files with relative filenames for 
the rastersources. When trying to load the created vrt file using a program 
that has been started from a different working dir, loading will give an 
error because gdal looks for the rastersources in the wrong dir. Or, even 
worse, you will not get an error but the wrong raster data if raster files 
with the same name as those mentioned in the vrt file are also present in the 
cwd...

On Tuesday 16 March 2004 09:48, Vincent Schut wrote:
> I'm starting to use (and like!) the vrt format more and more. However, when
> I thought I would use standard vrt files as templates for multiple
> directories that contain the same kind of data (like spot vegetation data
> for multiple dates), I found out that the vrt file loader uses the current
> working dir as path prefix for the SourceFilename, which effectively keeps
> me from using one .vrt file with relative filenames as SourceFilename and
> linking/copying that into each directory. E.g. I would like to have a vrt
> file that has the files 0001_B0.HDF, 0001_B2.HDF, 0001_B3.HDF and
> 0001_MIR.HDF as bands 1-4, and than I put that vrt file in each of my Spot
> Vegetation directories and if I then load one of the vrt files, it gives me
> the four HDF files from the directory where the vrt file is located.
> However, the current behaviour is different: it gives me the HDF files from
> the current directory. So if I issue a gdalinfo command on a vrt file from
> a different directory: vincent at lowresbox spotgetation/s10$ gdalinfo
> Asian-Islands.20020601/spectral.vrt
> gdal tries to load the referenced raster sources from the current directory
> (spotvegetation/s10/), and not from the local directory of the vrt file
> (spotvegetation/s10/Asian-Islands.20020601/). So in this example I would
> get an error, as there are no Spot Vegetation raster files in
> spotvegetation/s10/.
>
> 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.
>
> Thanks,

-- 
-----------------------------
 Vincent Schut
 SarVision B.V.
 Wageningen, The Netherlands
 www.sarvision.com



More information about the Gdal-dev mailing list