Opened 7 years ago
Closed 7 years ago
#6766 closed defect (wontfix)
gdalbuildvrt doesn't work from command line, only in qgis
Reported by: | saultdon | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Utilities | Version: | 2.1.2 |
Severity: | blocker | Keywords: | |
Cc: |
Description
Getting some odd behaviour merging some dems with gdalbuildvrt.
From the command line on Linux or Windows I use:
gdalbuildvrt output/cded_dem.vrt input/*.dem
The output vrt on both systems only contain NaN values (all black raster).
If I use QGIS through Raster > Miscellaneous > Build Virtal Raster (Catalog) tool, and select either option Use visible raster layers as input or Choose input directory instead of files then it works with expected output.
DEMs I'm using are available as open data at https://pub.data.gov.bc.ca/datasets/175624/ so feel free to download any amount required for testing.
Running GDAL 2.1.r37067 built from source code at github based on current release.
Change History (4)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
Maybe this is a QGIS issue...
WIth GDAL at command line:
saultdon@archasus ~/GIS/Data/bcgov/cded/250k % gdalbuildvrt _results/cded_102i08.vrt _extracted/102i08*.dem saultdon@archasus ~/GIS/Data/bcgov/cded/250k % gdalinfo -mm _results/cded_102i08.vrt Driver: VRT/Virtual Raster Files: _results/cded_102i08.vrt _extracted/102i08_e.dem _extracted/102i08_w.dem Size is 2401, 1201 Coordinate System is: GEOGCS["NAD83", DATUM["North_American_Datum_1983", SPHEROID["GRS 1980",6378137,298.257222101, AUTHORITY["EPSG","7019"]], TOWGS84[0,0,0,0,0,0,0], AUTHORITY["EPSG","6269"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.0174532925199433, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4269"]] Origin = (-128.500104166666659,50.500104166666667) Pixel Size = (0.000208333333333,-0.000208333333333) Corner Coordinates: Upper Left (-128.5001042, 50.5001042) (128d30' 0.37"W, 50d30' 0.37"N) Lower Left (-128.5001042, 50.2498958) (128d30' 0.37"W, 50d14'59.63"N) Upper Right (-127.9998958, 50.5001042) (127d59'59.63"W, 50d30' 0.37"N) Lower Right (-127.9998958, 50.2498958) (127d59'59.63"W, 50d14'59.63"N) Center (-128.2500000, 50.3750000) (128d15' 0.00"W, 50d22'30.00"N) Band 1 Block=128x128 Type=Int16, ColorInterp=Undefined Computed Min/Max=0.000,406.000 NoData Value=-32767
From QGIS GUI:
saultdon@archasus ~/GIS/Data/bcgov/cded/250k % gdalinfo -mm _results/cded_102i08_qgis.vrt Driver: VRT/Virtual Raster Files: _results/cded_102i08_qgis.vrt /home/saultdon/GIS/Data/bcgov/cded/250k/_extracted/102i08_w.dem /home/saultdon/GIS/Data/bcgov/cded/250k/_extracted/102i08_e.dem Size is 2401, 1201 Coordinate System is: GEOGCS["NAD83", DATUM["North_American_Datum_1983", SPHEROID["GRS 1980",6378137,298.257222101, AUTHORITY["EPSG","7019"]], TOWGS84[0,0,0,0,0,0,0], AUTHORITY["EPSG","6269"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.0174532925199433, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4269"]] Origin = (-128.500104166666659,50.500104166666667) Pixel Size = (0.000208333333333,-0.000208333333333) Corner Coordinates: Upper Left (-128.5001042, 50.5001042) (128d30' 0.37"W, 50d30' 0.37"N) Lower Left (-128.5001042, 50.2498958) (128d30' 0.37"W, 50d14'59.63"N) Upper Right (-127.9998958, 50.5001042) (127d59'59.63"W, 50d30' 0.37"N) Lower Right (-127.9998958, 50.2498958) (127d59'59.63"W, 50d14'59.63"N) Center (-128.2500000, 50.3750000) (128d15' 0.00"W, 50d22'30.00"N) Band 1 Block=128x128 Type=Int16, ColorInterp=Undefined Computed Min/Max=0.000,406.000 NoData Value=-32767
Do you have time to test what the GDAL built vrt displays as in QGIS? Mine comes up all black.
Also noticed that if I try to compute the histogram in QGIS for the vrt built with GDAL, an error window pops up:
Exception std::bad_array_new_length
Also notice the difference in the "Files:" portion where the GDAL generated VRT has relative paths, but the QGIS ones uses Absolute Paths.
They both contain the tag relativeToVRT="0" so I tried changing the GDAL one to relativeToVRT="1" and re-save but didn't work.
comment:3 by , 7 years ago
I also had to prefix the source file path with ../ along with relativeToVRT="1"
So in the end I had to modify the .vrt to go from:
<SourceFilename relativeToVRT="0">_extracted/102i08_e.dem</SourceFilename>
to:
<SourceFilename relativeToVRT="1">../_extracted/102i08_e.dem</SourceFilename>
comment:4 by , 7 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
OK, I see. As output/ and input/ have no direct hierarchical relationship, gdalbuildvrt use the paths directly. Technically this is correct if the output/cded_dem.vrt is opened from the directory where the gdalbuildvrt command line has been invoked, but this will not be the case from QGIS.
A solution is to force the use of absolute paths with:
gdalbuildvrt $PWD/output/cded_dem.vrt $PWD/input/*.dem
I cannot reproduce on Linux with latest 2.1: