st_dist_rcpp: RcppParallel version of 'st_distance'

View source: R/spatial_functions.R

st_dist_rcppR Documentation

RcppParallel version of st_distance

Description

RcppParallel version of st_distance

Usage

st_dist_rcpp(x, y = x, unit = "mi")

Arguments

x

Object of class sf/sfc or a matrix of coordinates. If a matrix of coordinates, use column order from st_coordinates().

y

Optional. Object of class sf/sfc or a matrix of coordinates. If a matrix of coordinates, use column order from st_coordinates(). If not included, x is used.

unit

Either "mi", "km", or "m". Sets the output distance.

Value

Matrix of distances of dimension n_x by n_y.

Examples

library(sf)
nc <- st_read(system.file("shape/nc.shp", package="sf"))
st_dist_rcpp(nc[1:3,])

nc_long <- nc[rep(seq_len(nrow(nc)), 5), ]
sf::st_distance(nc_long)
st_dist_rcpp(nc_long)


kylebutts/kfbmisc documentation built on April 17, 2025, 5:20 p.m.