View source: R/extract_spatial_information.R
extract_spatial_information | R Documentation |
This function returns a matrix
of distances between locations (in
kilometers) along with a vector of surface areas for the locations (in square
kilometers).
extract_spatial_information(
geometry,
id = NULL,
great_circle = FALSE,
show_progress = FALSE
)
geometry |
A spatial object that can be handled by the |
id |
The name or number of the column to use as |
great_circle |
A |
show_progress |
A |
The geometry
must be projected in a valid coordinate reference system (CRS).
By default, if great_circle = TRUE
, the coordinates will be reprojected in
degrees longitude/latitude to compute great-circle
distances between centroids using an internal function, and surface areas
will be
calculated using sf::st_area()
. If great_circle = FALSE
, the coordinates
are assumed to be planar (e.g., in meters) and Euclidean distances will
be used.
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).
The outputs are based on the locations contained in geometry
and
sorted in the same order. An optional id
can also be provided to be used as
names for the outputs.
Maxime Lenormand (maxime.lenormand@inrae.fr)
Associated functions:
extract_distances()
extract_opportunities()
data(county)
res <- extract_spatial_information(county, id = "ID")
dim(res$distance)
length(res$surface)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.