[Qgis-user] Virtual rasters and relative paths

Alex Mandel tech_dev at wildintellect.com
Fri Mar 11 18:40:12 PST 2016


On 2016-02-25 07:25, Richard Burkmar wrote:
> I created a virtual raster from a number of raster files (jpegs) all in one
> folder through the interface available from Raster>Miscellaneous>Build
> Virtual Raster. I saved the VRT file to the same folder as the raster
> images. I open as a VRT and all is well.
> 
> But if I copy the folder to another location, the VRT breaks when I open
> it. So I looked at the VRT file in Notepad++ and, sure enough, the
> pathnames to all the raster files are full pathnames instead of relative
> pathnames which is why moving the folder breaks it.
> 
> I assumed that if I saved the VRT in, or in a parent folder of, the folder
> with the raster images, then the paths to the rasters would be relative. I
> can't see an option to explicitly specify relative pathnames. I tried
> saving the VRT in the parent folder of the rasters but still it saves full
> pathnames. I tried specifying rasters using both 'all visible' and 'all in
> folder' method with the same result.
> 
> The actual paths in the VRT file look like this:
> 
> <SourceFilename
> relativeToVRT="0">E:\ExerciseData\Raster\PM\pm4.jpeg</SourceFilename>
> 
> It looks like the relativeToVRT attribute should be set to 1 to make
> relative paths, but how do I specify that from the
> Raster>Miscellaneous>Build Virtual Raster interface?
> 
> I'm using QGIS 2.12.3 from the standalone installer for Windows 64 bit.
> 
> Rich
> 
>

I just checked http://www.gdal.org/gdalbuildvrt.html it does not appear
that an option to make relative paths is exposed by the tool. I think we
should file an enhancement ticket with gdal for the feature. That would
be the best long term solution.

Short term seems like changing that value to relative and then doing a
find and replace on the path strings with a text editor (or if you want
to get fancy python or sed).

Bummer,
Alex




More information about the Qgis-user mailing list