redist | R Documentation |
Finds distances in km between data provided as sf dataframe with point geometry and regions provided as sf dataframe with polygon or multipolygon geometry.
redist(data, regions, region_id, max_dist, cores = 1, progress = FALSE)
data |
An sf data frame with point geometry. |
regions |
An sf dataframe with polygon or multipolygon geometry. |
region_id |
Optional name of column in 'regions' that contains the id that each region belongs to (no quotes). If null, it will be assumed that each row is its own region. |
max_dist |
a maximum distance that is needed for future calculations. (Set equal to maximum 'smooth' when predicting on new observations.) |
cores |
Number of cores for parallel computing. 'cores' above default of 1 will require more memory. (Progress bar only appears if ' cores' = 1.) |
progress |
If true, a text progress bar is printed to the console. Progress set to FALSE will find distances quicker if max_dist is not specified. |
A matrix where each row corresponds one-to-one with each row in provided 'data'. Matrix columns are either named with regions from 'region_id' column of 'regions' or the row numbers of 'regions' if 'region_id' is missing. Values are in kilometers.
remap
- uses redist for regional models.
library(remap)
data(utsnow)
data(utws)
# Build a matrix of distances between objects of utsnow and utws
# We will not set max_dist, so all distances will be found
dists <- redist(
data = utsnow,
regions = utws,
region_id = HUC2
)
head(dists)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.