rasterize_data {AgePopDenom} | R Documentation |
Rasterize Spatial Data
Description
This function converts spatial data with x, y coordinates and a value field into a raster using a specified resolution and CRS.
Usage
rasterize_data(x_coords, y_coords, values, cell_size = 5000, crs, fun = mean)
Arguments
x_coords |
Numeric vector of x-coordinates (e.g., longitude). |
y_coords |
Numeric vector of y-coordinates (e.g., latitude). |
values |
Numeric vector of values associated with each point. |
cell_size |
Numeric. Grid cell size in meters (default: 5000). |
crs |
Character, the coordinate reference system in EPSG format (e.g., "EPSG:3857"). |
fun |
Function to aggregate values in cells (default is 'mean'). |
Value
A 'terra::SpatRaster' object.
Examples
x_coords <- runif(100, -100, 100)
y_coords <- runif(100, -50, 50)
values <- rnorm(100, mean = 10, sd = 5)
rasterize_data(x_coords, y_coords, values,
cell_size = 5000, crs = "EPSG:3857", fun = mean)
[Package AgePopDenom version 1.2.2 Index]