Opened 11 years ago

Closed 9 years ago

#5207 closed enhancement (wontfix)

gdalbuildvrt handling of relative paths

Reported by: lpinner Owned by: warmerdam
Priority: low Milestone:
Component: Utilities Version: 1.10.0
Severity: minor Keywords: gdalbuildvrt
Cc: antonio

Description (last modified by lpinner)

Currently gdalbuildvrt doesn't set the "relativeToVRT" attribute correctly when the output vrt is not in the same directory that the command was run from. e.g:

$ gdalbuildvrt ../test.vrt test1.tif test2.tif
$ cat ../test.vrt
<VRTDataset rasterXSize="250" rasterYSize="500">
  <GeoTransform> 0.0000000000000000e+000, 1.0000000000000000e+000, 0.0000000000000000e+000, 5.0000000000000000e+002, 0.0000000000000000e+000,-1.0000000000000000e+000</GeoTransform>
  <VRTRasterBand dataType="Byte" band="1">
    <NoDataValue>0.00000000000000E+000</NoDataValue>
    <ComplexSource>
      <SourceFilename relativeToVRT="0">test1.tif</SourceFilename>
      <SourceBand>1</SourceBand>
      <SourceProperties RasterXSize="250" RasterYSize="250" DataType="Byte" BlockXSize="256" BlockYSize="16" />
      <SrcRect xOff="0" yOff="0" xSize="250" ySize="250" />
      <DstRect xOff="0" yOff="250" xSize="250" ySize="250" />
      <NODATA>0</NODATA>
    </ComplexSource>
    <ComplexSource>
      <SourceFilename relativeToVRT="0">test2.tif</SourceFilename>
      <SourceBand>1</SourceBand>
      <SourceProperties RasterXSize="250" RasterYSize="250" DataType="Byte" BlockXSize="256" BlockYSize="16" />
      <SrcRect xOff="0" yOff="0" xSize="250" ySize="250" />
      <DstRect xOff="0" yOff="0" xSize="250" ySize="250" />
      <NODATA>0</NODATA>
    </ComplexSource>
  </VRTRasterBand>
</VRTDataset>

The obvious workaround is: gdalbuildvrt test.vrt dir/test1.tif dir/test2.tif but I often forget that :) so requesting an enhancement to handle relative paths better.

Change History (4)

comment:1 by antonio, 11 years ago

Cc: antonio added

comment:2 by lpinner, 11 years ago

Description: modified (diff)

comment:3 by Jukka Rahkonen, 11 years ago

Hi,

So your image files are /dir/test1.tif and /dir2.tif and you write the vrt file one level up in the directory tree? What do you want to happen then? Is it like this

<SourceFilename relativeToVRT="1">dir/test1.tif</SourceFilename>

What if you are in Windows your working directory is for example d:\data\satellite_images and you decide to write the vrt file into c:\data\vrt_files as

gdalbuildvrt c:\data\vrt_files\path_test.vrt test1.tif test2.tif

Relative paths can't work in such case. I would say that you had better make your vrt directory as your working directory and run gdalbuildvrt from there as

gdalbuildvrt test.vrt dir/test1.tif dir/test2.tif

You call it workaround but I would call it the right way to do the job. However, I may have misunderstood your goal.

comment:4 by Jukka Rahkonen, 9 years ago

Resolution: wontfix
Status: newclosed

Closing as wontfix. Reopen if it hurts.

Note: See TracTickets for help on using tickets.