Parses a GDAL VRT file, validates that it is a simple mosaic, computes tile footprint polygons from the DstRect pixel coordinates and GeoTransform, and writes a GTI-compatible vector dataset (GeoPackage by default) with appropriate layer metadata.
vrt_to_gti(
dsn,
output,
layer = "tile_index",
location_field = "location",
relative_paths = FALSE,
overwrite = FALSE
)Character string. Path or URL to a VRT file. Supports
/vsicurl/ prefixed URLs.
Character string. Output file path. The format is inferred
from the extension: .gpkg for GeoPackage (default recommendation),
.fgb for FlatGeoBuf. These formats support layer metadata required
by GTI.
Character string. Layer name in the output dataset.
Defaults to "tile_index".
Character string. Name of the field that stores
tile file paths. Defaults to "location" (the GTI default).
Logical. If TRUE, store paths relative to the
output file location. If FALSE (default), store absolute/resolved paths.
Logical. If TRUE, delete existing output file before
writing.
Invisibly, the output file path. The file can be opened as a GTI
raster datasource, e.g. GTI:<output>.
The function performs the following steps:
Parse: Read the VRT XML and extract source information.
Validate: Ensure the VRT is a simple mosaic (SimpleSource only, consistent bands, no resampling).
Compute extents: Convert DstRect pixel coordinates to geographic extents using the VRT's GeoTransform. Extents are pixel-edge aligned.
Resolve paths: Handle relativeToVRT attributes, resolving source
file paths against the VRT location.
Write: Create a GeoPackage (or FlatGeoBuf) with polygon footprints
and a location field, using gdalraster::GDALVector.
Set metadata: Write GTI layer metadata items (RESX, RESY, MINX, MINY, MAXX, MAXY, BAND_COUNT, DATA_TYPE, NODATA, SRS).
if (FALSE) { # \dontrun{
vrt_to_gti(
dsn = "/vsicurl/https://example.com/REMA-2m_dem_ovr.vrt",
output = "rema_tiles.gpkg"
)
# Open with GDAL
library(gdalraster)
ds <- new(GDALRaster, "GTI:rema_tiles.gpkg")
} # }