Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

rij_matrix

Feature by planning unit matrix


Description

Generate a matrix showing the amount of each feature in each planning unit (also known as an rij matrix).

Usage

rij_matrix(x, y, ...)

## S4 method for signature 'Raster,Raster'
rij_matrix(x, y, ...)

## S4 method for signature 'Spatial,Raster'
rij_matrix(x, y, fun, ...)

## S4 method for signature 'sf,Raster'
rij_matrix(x, y, fun, ...)

Arguments

x

Raster, Spatial, or sf::sf() object representing the planning units.

y

Raster object representing the features.

...

not used.

fun

character for summarizing values inside each planning unit. This parameter is only used when the argument to x is a Spatial or sf::sf() object. Defaults to "sum".

Details

Generally, processing vector (i.e. Spatial or sf::sf()) data takes much longer to process then Raster data, so it is recommended to use Raster data for planning units where possible.

Value

dgCMatrix sparse matrix object. The sparse matrix represents the spatial intersection between the planning units and the features. Rows correspond to features, and columns correspond to planning units. Values correspond to the amount (or presence/absence) of the feature in the planning unit. For example, the amount of the third species in the second planning unit would be stored in the third column and second row.

Examples

# load data
data(sim_pu_raster, sim_pu_polygons, sim_pu_sf, sim_pu_zones_stack)

# create rij matrix using raster layer planning units
rij_raster <- rij_matrix(sim_pu_raster, sim_features)
print(rij_raster)

# create rij matrix using polygon (Spatial) planning units
rij_polygons <- rij_matrix(sim_pu_polygons, sim_features)
print(rij_polygons)

# create rij matrix using polygon (sf) planning units
rij_sf <- rij_matrix(sim_pu_sf, sim_features)
print(rij_sf)

# create rij matrix using raster stack planning units
rij_zones_raster <- rij_matrix(sim_pu_zones_stack, sim_features)
print(rij_zones_raster)

prioritizr

Systematic Conservation Prioritization in R

v7.0.1
GPL-3
Authors
Jeffrey O Hanson [aut] (<https://orcid.org/0000-0002-4716-6134>), Richard Schuster [aut, cre] (<https://orcid.org/0000-0003-3191-7869>), Nina Morrell [aut], Matthew Strimas-Mackey [aut] (<https://orcid.org/0000-0001-8929-7776>), Matthew E Watts [aut], Peter Arcese [aut] (<https://orcid.org/0000-0002-8097-482X>), Joseph Bennett [aut] (<https://orcid.org/0000-0002-3901-9513>), Hugh P Possingham [aut] (<https://orcid.org/0000-0001-7755-996X>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.