Learn R Programming

amadeus (version 1.2.3)

calculate_groads: Calculate roads covariates

Description

Prepared groads data is clipped with the buffer polygons of radius. The total length of the roads are calculated. Then the density of the roads is calculated by dividing the total length from the area of the buffer. terra::linearUnits() is used to convert the unit of length to meters.

Usage

calculate_groads(
  from = NULL,
  locs = NULL,
  locs_id = NULL,
  radius = 1000,
  fun = "sum",
  geom = FALSE,
  ...
)

Value

a data.frame or SpatVector object

Arguments

from

SpatVector(1). Output of process_groads.

locs

data.frame, characater to file path, SpatVector, or sf object.

locs_id

character(1). Column within locations CSV file containing identifier for each unique coordinate location.

radius

integer(1). Circular buffer distance around site locations. (Default = 1000).

fun

function(1). Function used to summarize the length of roads within sites location buffer (Default is sum).

geom

FALSE/"sf"/"terra".. Should the function return with geometry? Default is FALSE, options with geometry are "sf" or "terra". The coordinate reference system of the sf or SpatVector is that of from.

...

Placeholders.

Author

Insang Song

See Also

process_groads

Examples

Run this code
## NOTE: Example is wrapped in `\dontrun{}` as function requires a large
##       amount of data which is not included in the package.
if (FALSE) {
loc <- data.frame(id = "001", lon = -78.90, lat = 35.97)
calculate_groads(
  from = groads, # derived from process_groads() example
  locs = loc,
  locs_id = "id",
  radius = 1000,
  fun = "sum",
  geom = FALSE
)
}

Run the code above in your browser using DataLab