r.buildvrt.gdal
Build GDAL Virtual Rasters (VRT) over GRASS GIS raster maps
r.buildvrt.gdal [-mr] [input=name [,name,...]] [file=name] [vrt_directory=name] output=name [--overwrite] [--verbose] [--quiet] [--qq] [--ui]
Example:
r.buildvrt.gdal input=name output=name
grass.script.run_command("r.buildvrt.gdal", input=None, file=None, vrt_directory=None, output, flags=None, overwrite=False, verbose=False, quiet=False, superquiet=False)
Example:
gs.run_command("r.buildvrt.gdal", input="name", output="name")
Parameters
input=name [,name,...]
Name of input raster map(s)
file=name
Name of input file
vrt_directory=name
Directory to store GDAL VRT files in. Default is: $GISDBASE/$PROJECT/$MAPSET/gdal
output=name [required]
Name for output raster map
-m
Read data range from metadata
WARNING: metadata are sometimes approximations with wrong data range
-r
Create fast link without data range
WARNING: some modules do not work correctly without known data range
--overwrite
Allow output files to overwrite existing files
--help
Print usage summary
--verbose
Verbose module output
--quiet
Quiet module output
--qq
Very quiet module output
--ui
Force launching GUI dialog
input : str | list[str], optional
Name of input raster map(s)
Used as: input, raster, name
file : str, optional
Name of input file
Used as: input, file, name
vrt_directory : str, optional
Directory to store GDAL VRT files in. Default is: $GISDBASE/$PROJECT/$MAPSET/gdal
Used as: input, dir, name
output : str, required
Name for output raster map
Used as: output, raster, name
flags : str, optional
Allowed values: m, r
m
Read data range from metadata
WARNING: metadata are sometimes approximations with wrong data range
r
Create fast link without data range
WARNING: some modules do not work correctly without known data range
overwrite: bool, optional
Allow output files to overwrite existing files
Default: False
verbose: bool, optional
Verbose module output
Default: False
quiet: bool, optional
Quiet module output
Default: False
superquiet: bool, optional
Very quiet module output
Default: False
DESCRIPTION
r.buildvrt.gdal builds GDAL virtual rasters over GRASS GIS raster maps and links them to the mapset with r.external. The module is written as a workaround for a limitation in GRASS GIS Virtual Rasters (VRT) format with GDAL-linked raster maps (through r.external / r.external.out. In that case GRASS GIS Virtual Rasters currently show performance issues. See: #4345
For the resulting maps GDAL VRT text files are created either in a directory named "gdal" in the current mapset or in a user-defined vrt_directory. Those files are not removed when the raster map is removed and the user is responsible for removing them when needed.
REQUIREMENTS
r.buildvrt.gdal uses the Python bindings for GDAL and requires the GDAL-GRASS driver to include raster maps in native GRASS format in GDAL VRTs.
EXAMPLES
# Create external example data
regs='s,0,1000
n,500,1500'
eval `g.gisenv`
external_path="${GISDBASE}/${LOCATION}/${MAPSET}/.tmp/vrt"
mkdir -p "$external_path"
for reg in $regs
do
r=$(echo $reg | cut -f1 -d",")
s=$(echo $reg | cut -f2 -d",")
n=$(echo $reg | cut -f3 -d",")
g.region -g n=$n s=$s w=0 e=1000 res=1
r.external.out format=GTiff options="compress=LZW,PREDICTOR=3" \
directory="$external_path"
r.mapcalc --o --v expression="${r}_${s}_gtiff_ntfs=float(x()*y())"
done
# Run performance tests
g.region -g n=1500 s=0 w=0 e=1000 res=1
format_type=gtiff_ntfs
rmaps=$(g.list type=raster pattern="*_*_${format_type}", sep=",")
# Using GRASS GIS VRT
r.buildvrt --o --v input="$rmaps" output=vrt_${format_type}
time r.univar map=vrt_${format_type}
# Using GDAL VRT
r.buildvrt.gdal --o --v input="$rmaps" output=vrt_${format_type}_gdal
time r.univar map=vrt_${format_type}_gdal
SEE ALSO
r.buildvrt, r.patch, r.external, r.external.out
AUTHORS
Stefan Blumentrath
SOURCE CODE
Available at: r.buildvrt.gdal source code
(history)
Latest change: Thursday Feb 20 13:02:26 2025 in commit 53de819