Warps a .vec raster onto a target grid, walking the output one tile-row
strip at a time. For each strip the target pixel-centre coordinates are built,
projected into the source coordinate reference system when the two CRSs differ
(delegated to PROJ via sf), mapped through the source geotransform to
fractional source pixels, and sampled from the bounded source window those
coordinates fall in. The output is assembled in memory or streamed straight
back to a new .vec, so the whole output grid is never resident; the source
is read in bounded windows rather than held whole.
Arguments
- x
A
vectra_raster(fromvec_open_raster()) or a path to a.vecraster to warp.- template
The target grid: a
vectra_raster/.vecpath whose grid and CRS are borrowed, or a listlist(crs =, extent =, res =, dims =). Withcrsandresbut noextent, the target extent is the source's corners projected intocrs.- method
Resampling method:
"near","bilinear", or"cubic". Default"near".- band
Band to warp (1-based). Default 1.
- path
Optional output
.vecpath. When given the result is streamed to disk and the openedvec_open_raster()handle is returned invisibly; whenNULLthe result is returned as an in-memory matrix.- dtype
Storage dtype for
.vecoutput (seevec_write_raster()). Default"f32".- compression
Compression effort for
.vecoutput. Default"fast".
Value
When path is NULL, a numeric matrix on the target grid (row 1
northmost) carrying gt, extent, and crs attributes. When path is
given, the written vectra_raster handle (invisibly).
Details
This is the sort / partition tier of the spatial toolbox: each output strip reads the source window it projects onto. For a mild reprojection or a plain resample that window is a thin band; a strong reprojection can make it large, but the output stays streamed throughout.
Sampling follows the GDAL / terra convention (pixel centres at
half-integer coordinates). "near" takes the nearest source cell;
"bilinear" the 2x2 weighted mean; "cubic" the 4x4 cubic convolution
(Catmull-Rom, a = -0.5). A target cell whose sampling kernel reaches outside
the source extent, or touches a nodata cell, comes back NA.
Reprojection happens only when both rasters carry a known EPSG code and the
codes differ; otherwise warp() resamples within a shared CRS and needs no
sf.
See also
rasterize() to build a raster from streamed vector features,
focal() for moving-window statistics.