create_matrix: Create a Distance Matrix Between Two Spatial Objects

View source: R/create_matrix.R

create_matrixR Documentation

Create a Distance Matrix Between Two Spatial Objects

Description

This function creates a distance matrix between two spatial objects.

Usage

create_matrix(x, y, checksize = TRUE, longlat = FALSE)

Arguments

x

an sf object (POINT), rows of the distance matrix, row names are used as row names of the matrix.

y

an sf object (POINT), columns of the distance matrix, row names are used as column names of the matrix.

checksize

if FALSE, bypass the distance matrix size control (see Details).

longlat

if FALSE, the Euclidean distance is used, if TRUE Great Circle (WGS84 ellipsoid) distance is used.

Details

The function returns a full matrix of distances in meters. If the matrix to compute is too large (more than 100,000,000 cells, more than 10,000,000 origins or more than 10,000,000 destinations) the function may sends a message to warn users about the amount of RAM mobilized.

Value

A distance matrix, row names are x row names, column names are y row names.

Examples

g <- create_grid(x = n3_poly, res = 200000)
mat <- create_matrix(x = n3_pt, y = g)
mat[1:5, 1:5]

riatelab/potential documentation built on Jan. 2, 2023, 7:15 a.m.