pleistodist_euclidean: Calculate Euclidean distance between points

View source: R/calcmetrics.R

pleistodist_euclideanR Documentation

Calculate Euclidean distance between points

Description

This function calculates the straight-line distance ("as the crow flies) between user-specified points. Because these points are invariant across space and time and independent of sea level change, this calculation is only performed once instead of repeatedly across different sea level or time intervals.

Usage

pleistodist_euclidean(points, epsg, outdir)

Arguments

points

A user-generated multi-point shapefile (.shp) containing at least two points. If the shapefile attribute table contains a column labelled 'Name', the output distance matrix will use the identifiers in this column to label each pairwise comparison. Otherwise, the output distance matrix will use the attribute FID values instead.

epsg

The projected coordinate system in EPSG code format. Because of the curvature of the Earth's surface, we need to apply a map projection to accurately calculate straight-line distances between points instead of using the default WGS84 geographical coordinate system. Users should specify a projected coordinate system appropriate to the geographic region being analysed using the projection's associated EPSG code (https://epsg.org/home). Geographic coordinate system projections are not recommended as those will result in distance matrices calculated in decimal degrees rather than in distance units.

outdir

Output directory for the Euclidean distance matrix (island_euclideandist.csv). If the specified output directory doesn't already exist, PleistoDist will create the output directory.

Value

This function outputs a pairwise distance matrix of inter-point Euclidean distances in long format.

Examples

#create temp directory
path <- file.path(tempdir())
#create points shapefile
points <- sf::st_multipoint(rbind(c(179.41256,-17.79426), c(179.27600,-17.97850)))
#convert points to feature geometry
points <- sf::st_sfc(points)
points <- sf::st_cast(points, "POINT")
#set default projection (WGS84)
sf::st_crs(points) <- 4326
#save shapefile
sf::write_sf(points,paste0(path,"/points.shp"))
#Project input points using EPSG:3141 and calculate Euclidean distances
pleistodist_euclidean(points=paste0(path,"/points.shp"),epsg=3141,outdir=path)

g33k5p34k/PleistoDistR documentation built on Oct. 9, 2022, 5:27 a.m.