Learn R Programming

TDLM (version 1.1.1)

extract_spatial_information: Extract distances and surface areas from a spatial object

Description

This function returns a matrix of distances between locations (in kilometers) along with a vector of surface areas for the locations (in square kilometers).

Usage

extract_spatial_information(geometry, id = NULL, show_progress = FALSE)

Value

A list composed of two elements. The first element is a square matrix

representing the great-circle distances (in kilometers) between locations. The second element is a vector containing the surface area of each location (in square kilometers).

Arguments

geometry

A spatial object that can be handled by the sf package.

id

The name or number of the column to use as rownames and colnames for the output distance matrix (optional, NULL by default). A vector with a length equal to the number of locations can also be used.

show_progress

A boolean indicating whether a progress bar should be displayed.

Author

Maxime Lenormand (maxime.lenormand@inrae.fr)

Details

The geometry must be projected in a valid coordinate reference system. It will be reprojected in degrees longitude/latitude to compute the great-circle distances between centroids of locations using an internal function and to compute the surface area using the function st_area from the sf package.

See Also

'Associated functions: extract_distances() extract_opportunities()

Examples

Run this code
data(county)

res <- extract_spatial_information(county, id = "ID")

dim(res$distance)

length(res$surface)

Run the code above in your browser using DataLab