rasterize_data | R Documentation |
This function converts spatial data with x, y coordinates and a value field into a raster using a specified resolution and CRS.
rasterize_data(x_coords, y_coords, values, cell_size = 5000, crs, fun = mean)
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'). |
A 'terra::SpatRaster' object.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.