Learn R Programming

raceland (version 1.2.1)

zones_to_raster: Convert zones to rasters

Description

Convert zones to rasters

Usage

zones_to_raster(v, resolution, variables, ...)

Value

a SpatRaster

Arguments

v

An sf object (POLYGON or MULTIPOLYGON)

resolution

A numeric vector of length 1 or 2 to set the resolution

variables

A character vector with columns names from v. The values from these columns will be (1) rasterized and (2) recalculated to densities. Each column will be represented as an layer in the output RasterStack

...

Additional arguments as for terra::rasterize()

Examples

Run this code
library(sf)
library(terra)
plot(pop_vector)
popdens_raster = zones_to_raster(pop_vector, resolution = 30,
                                 variables = c("ASIAN", "BLACK", "HISPANIC", "OTHER", "WHITE"))
plot(popdens_raster)

Run the code above in your browser using DataLab