m_surr_cdt: A funcion for creating m-surroudings minimizing the distances

Description Usage Arguments Details Value Examples

View source: R/m_surr_cdt.R

Description

This function obtains the m-surroundings by choosing the m-1 nearest centroids. If there are less than m-1 neighbors the corresponding m-surrounding is filled with NA's

Usage

1
m_surr_cdt(x = x, m = m, r = r, control = NULL)

Arguments

x

input sf object with points/multipolygons geometry or matrix of spatial coordinates

m

length of m-surrounding

r

maximum overlap between any two m-surroundings

control

Argumento opcional. Por definir

Details

AquĆ­ Antonio escribe una linda historia

Value

REPASAR A list with SOME matrices: an m-surrounding matrix, named ms, whose rows correspond to the m-surroundings and a distance matrix, named mdtms, whose rows correspond to distance between the elements of m-surroundings.....

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
N <- 1000
m = 5
r = 2
cx <- runif(N)
cy <- runif(N)
x <- cbind(cx,cy)
msurr_points <- m_surr_cdt(x = x, m = m, r = r,
                           control = list(dtmaxabs = 0.05))
ms <- msurr_points$ms
mdtms <- msurr_points$mdtms
dim(ms); dim(mdtms)
ms[1:10,]
mdtms[1:10,]
# Examples with multipolygons
library(sf)
fname <- system.file("shape/nc.shp", package="sf")
nc <- st_read(fname)
plot(sf::st_geometry(nc))
lms3 <- m_surr_cdt(nc, m = 3, r = 2,
                   control = list(dtmaxpc = 0.1))
lms5 <- m_surr_cdt(nc, m = 5, r = 1,
                   control = list(dtmaxpc = 0.1))
# m-surroundings or m-histories
lms3$ms[1:3, ]; lms5$ms[1:3, ]
# Distances in m-surroundings
lms3$mdtms[1:3,]; lms5$mdtms[1:3,]

rominsal/spqdata documentation built on Jan. 24, 2021, 11:11 a.m.