
Build an analysis grid from a raster or vector source.
grid_from_src.RdDerives a GridSpec from any GDAL/OGR-readable file or URL. The two source
kinds are treated differently, because they carry different information:
Usage
grid_from_src(
x,
res,
projection = c("laea", "aeqd", "utm", "pconic", "eqdc"),
ellps = "WGS84",
buffer = 0,
dtype = "f32"
)Arguments
- x
Path or URL to a raster or vector source.
- res
Target resolution. For a raster, in the source's native CRS units; for a vector, in the chosen projected CRS units (see
grid_from_bbox()).- projection, ellps
Vector sources only; ignored for rasters.
- buffer, dtype
As in
grid_from_bbox().
Details
Raster (GeoTIFF, COG, ...): the source already has a projected CRS and footprint, so the grid keeps that native CRS and extent and is simply re-gridded to
res(the extent is snapped out to whole multiples ofres).projection/ellpsare ignored: reprojecting a raster's own grid would distort it. Use this to coarsen a tile in place, e.g. read a 10 m embedding COG onto a 30 m grid while preserving its geometry.Vector (GeoJSON, GeoPackage, shapefile, ...): only a footprint is known, so a projected CRS is chosen for it and the grid is built exactly as
grid_from_bbox()does, honouringprojection/ellps.
Remote sources are read via HTTP range requests (header only), so this does not download the whole file.
See also
grid_from_bbox() to build a grid from a lon/lat bounding
box; grid_spec() to build one from an explicit extent.