This function creates a distance matrix between two sp objects (SpatialPointsDataFrame or SpatialPolygonsDataFrame).
sp object; rows of the distance matrix.
sp object; columns of the distance matrix.
logical; bypass the distance matrix size control (see Details).
logical; if FALSE, Euclidean distance, if TRUE Great Circle (WGS84 ellipsoid) distance.
The function returns a full matrix of distances in meters.
This is a wrapper
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 sends a confirmation message to warn users about the amount of
bypassctrl = TRUE to skip this control.
A distance matrix, row names are
knownpts row names, column
unknownpts row names.
1 2 3 4 5 6 7 8 9 10
# Create a SpatialPointsDataFrame grid of spatMask extent and 200 meters # resolution data(spatData) mygrid <- CreateGrid(w = spatMask, resolution = 200) # Create a distance matrix between known spatPts and mygrid mymat <- CreateDistMatrix(knownpts = spatPts, unknownpts = mygrid) mymat[1:5,1:5] nrow(spatPts) nrow(mygrid) dim(mymat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.