nh_rasterize | R Documentation |
Requires spatial features with a prediction values attribute, and a
template raster. The buffer is optional; when provided, the
buffer distance can be provided as a single numeric value or a
vector matching length of spf
, for a variable buffer by feature.
nh_rasterize(
spf,
rast,
pred.vals,
buffer = NULL,
priority = NULL,
touches = TRUE,
rast.out = NULL,
...
)
spf |
input spatial features (model predictions; sp or sf spatial object) |
rast |
input raster template |
pred.vals |
column name in spf holding feature prediction values |
buffer |
numeric (single value or vector matching length of spf); spatial buffer around spf to include in burn-in |
priority |
column name in spf holding priority values for feature rasterization (higher values have priority) |
touches |
from |
rast.out |
Optional output raster file name (with file extension) |
... |
Additional arguments to terra::writeRaster (e.g. overwrite) |
Buffer units should be given in the units of rast
. Make
sure to keep in mind the resolution of the raster when choosing
a buffer. If rasterizing lines, and a one-cell width is desired,
do not use a buffer.
A vector can be given to 'priority' for sorting prior to rasterization,
where higher values have priority. When priority = NULL
(default),
priority will be defined as the pred.vals
.
If rast.out
is not specified, the raster will remain in temp folder.
SpatRaster
David Bucklin
## Not run:
spf <- st_read("_data/species/acipoxyr/outputs/model_predictions/acipoxyr_20180105_133929_results.shp")
rast <- terra::rast("_data/species/ambymabe/outputs/model_predictions/ambymabe_20171018_130837.tif")
# rasterize
rast_poly <- nh_rasterize(spf, rast, pred.vals = "prbblty", priority = "strord",
buffer = spf$strord*15, touches=F, rast.out = "C:/David/scratch/nh_rasterize_poly.tif",
overwrite = T)
rast_line <- nh_rasterize(spf, rast, pred.vals = "prbblty", priority = "strord", touches=T,
rast.out = "C:/David/scratch/nh_rasterize_line.tif", overwrite = T)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.