footprint()
is a wrapper of the gdal_footprint
command-line
utility (see https://gdal.org/programs/gdal_footprint.html).
The function can be used to compute the footprint of a raster file, taking
into account nodata values (or more generally the mask band attached to
the raster bands), and generating polygons/multipolygons corresponding to
areas where pixels are valid, and write to an output vector file.
Refer to the GDAL documentation at the URL above for a list of command-line
arguments that can be passed in cl_arg
. Requires GDAL >= 3.8.
Arguments
- src_filename
Character string. Filename of the source raster.
- dst_filename
Character string. Filename of the destination vector. If the file and the output layer exist, the new footprint is appended to them, unless the
-overwrite
command-line argument is used.- cl_arg
Optional character vector of command-line arguments for
gdal_footprint
.
Details
Post-vectorization geometric operations are applied in the following order:
optional splitting (
-split_polys
)optional densification (
-densify
)optional reprojection (
-t_srs
)optional filtering by minimum ring area (
-min_ring_area
)optional application of convex hull (
-convex_hull
)optional simplification (
-simplify
)limitation of number of points (
-max_points
)
Examples
evt_file <- system.file("extdata/storml_evt.tif", package="gdalraster")
out_file <- file.path(tempdir(), "storml.geojson")
# Requires GDAL >= 3.8
if (as.integer(gdal_version()[2]) >= 3080000) {
# command-line arguments for gdal_footprint
args <- c("-t_srs", "EPSG:4326")
footprint(evt_file, out_file, args)
DONTSHOW({deleteDataset(out_file)})
}