OSGeo / grass

GRASS GIS - free and open-source geospatial processing engine
https://grass.osgeo.org
Other
823 stars 302 forks source link

[Bug] GDAL VRT with Int8 data type fail to import #4230

Open ninsbl opened 2 weeks ago

ninsbl commented 2 weeks ago

Describe the bug

r.in.gdal and r.external fail to import GDAL Virtual Rasters (VRT) with Int8 datatype. Int8 was relatively recently introduced to GDAL (3.7) and then made available in VRT datasets. While GRASS GIS reads Int8 data in GeoTiff format, it fails with that datatype in VRT format.

To reproduce

# Create a Int8 raster in GeoTiff
gdal_create -ot Int8 -of GTiff -outsize 24 24 -burn 1 -a_srs EPSG:25833 -a_ullr 0 24 24 0 ./test.tif
# Create a VRT from it
gdal_translate -of VRT ./test.tif ./test.vrt
# Import the GeoTiff (works)
r.in.gdal -o input=test.tif output=test.tif
# Try to import the VRT (fails)
r.in.gdal -o input=test.vrt output=test.vrt
r.external -o input=test.vrt output=test.vrt

The last two commands fail with:

ERROR 1: Invalid dataType = Int8
ERROR: Unable to open datasource <test.vrt>

Expected behavior

GRASS GIS should import VRT with Int8 data.

System description

Additional context

GRASS GIS does not seem to be the only one here: https://community.safe.com/data-7/int8-gdal-vrt-raster-not-supported-by-fme-18505

neteler commented 2 weeks ago

I guess it is "easy" to fix by adding GDT_Int8 support here (possibly with a test for the minimum required GDAL version, i.e. 3.7):

https://github.com/OSGeo/grass/blob/4aa4abf43f69d23ecdea932f3e550b5479df428f/raster/r.external/link.c#L17