##R Markdown en creaciĂ³n, utilizar con precauciĂ³n.

Patrones Espaciales Puntuados

En el presente documento de R Markdown se presentan el anĂ¡lisis de Patrones Espaciales Puntuados. Se generaron en QGIS un polĂ­gono cuadrado (ventana) y dentro de la ventana se generaron tres shapes con los siguientes patrones:

  1. Conglomerado
  2. Aleatorio
  3. Equidistante

Para generar la ventana se extrajeron los vĂ©rtices y se calcularon las coordenadas (GTM), tanto para la ventana cĂ³mo para los tres patrones generados. Posteriormente, se exportĂ³ la tabla asociada en formato CSV.

Jalar los ficheros CSV desde su lugar de origen al de trabajo

Desde la Terminal de R, ejecutar los siguientes comandos. Se deberĂ¡n modificar la ubicaciĂ³n de acuerdo al ordenador

cp /media/manuel/MBARRIOS/GIS/SpatialPointPattern/clustered1.csv ./CSV-files/ cp /media/manuel/MBARRIOS/GIS/SpatialPointPattern/random1.csv ./CSV-files/ cp /media/manuel/MBARRIOS/GIS/SpatialPointPattern/equidistant1.CSV ./CSV-files/ cp /media/manuel/MBARRIOS/GIS/SpatialPointPattern/window1.CSV ./CSV-files/

PPP

Cargar las librerĂ­as

library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(maptools)
## Loading required package: sp
## Checking rgeos availability: FALSE
## Please note that 'maptools' will be retired by the end of 2023,
## plan transition at your earliest convenience;
## some functionality will be moved to 'sp'.
##      Note: when rgeos is not available, polygon geometry     computations in maptools depend on gpclib,
##      which has a restricted licence. It is disabled by default;
##      to enable gpclib, type gpclibPermit()
library(spatstat)
## Loading required package: spatstat.data
## Loading required package: spatstat.geom
## spatstat.geom 2.4-0
## Loading required package: spatstat.random
## spatstat.random 2.2-0
## Loading required package: spatstat.core
## Loading required package: nlme
## 
## Attaching package: 'nlme'
## The following object is masked from 'package:dplyr':
## 
##     collapse
## Loading required package: rpart
## spatstat.core 2.4-4
## Loading required package: spatstat.linnet
## spatstat.linnet 2.3-2
## 
## spatstat 2.3-4       (nickname: 'Watch this space') 
## For an introduction to spatstat, type 'beginner'

Cargar los ficheros de las localidades muestreadas

cluster<-read.csv("./CSV-files/clustered1.csv", header=T, sep=',')
equidistant<-read.csv("./CSV-files/equidistant1.csv", header=T, sep=',')
random<-read.csv("./CSV-files/random1.csv", header=T, sep=',')

names(cluster); names(equidistant); names(random)
## [1] "id" "X"  "Y"
## [1] "id" "X"  "Y"
## [1] "rand_point" "id"         "X"          "Y"

Window

Crear el objeto con las coordenadas de la ventana

window<-read.csv("./CSV-files/window1-vert.csv", header=T, sep=',')
names(cluster); names(equidistant); names(random)
## [1] "id" "X"  "Y"
## [1] "id" "X"  "Y"
## [1] "rand_point" "id"         "X"          "Y"

Crear la ventana con el comando owin

Mask <- read.csv('./CSV-files/window1-vert.csv',sep = ',',header=T) 
W1 <- owin(poly=data.frame(x=rev(Mask$X), y=rev(Mask$Y)))
plot(W1)

Modelos

Preparar el archivo PPP para clustered

En los siguientes diagramas se despliegan los modelos de densidad, KRipleys, KRipleys envelopes y L-transformation

p.clustered<-ppp(cluster$X, cluster$Y, window=W1)
## Warning: data contain duplicated points
p2.clustered<- as.ppp(p.clustered)#remueve los puntos ilegales

plot(p2.clustered) # Imprimir los puntos

DD.p2.clustered <- density(p2.clustered)
plot(DD.p2.clustered) #Imprimir la desnisad

KK.p2.clustered<- Kest(p2.clustered)
plot(KK.p2.clustered) #Realizar la prueba de Ripleys K-function

plot(envelope(p2.clustered,Kest))
## Generating 99 simulations of CSR  ...
## 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, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
## 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
## 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,  99.
## 
## Done.

plot(envelope(p2.clustered,Lest, nsim=1000,fix.n = T))
## Generating 1000 simulations of CSR with fixed number of points  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990......... 1000.
## 
## Done.

Preparar el archivo PPP para random

En los siguientes diagramas se despliegan los modelos de densidad, KRipleys, KRipleys envelopes y L-transformation

p.random<-ppp(random$X, random$Y, window=W1)
p2.random<- as.ppp(p.random)#remueve los puntos ilegales

plot(p2.random) # Imprimir los puntos

DD.p2.random <- density(p2.random)
plot(DD.p2.random) #Imprimir la desnisad

KK.p2.random<- Kest(p2.random)
plot(KK.p2.random) #Realizar la prueba de Ripleys K-function

plot(envelope(p2.random,Kest))
## Generating 99 simulations of CSR  ...
## 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, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
## 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
## 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,  99.
## 
## Done.

plot(envelope(p2.random,Lest, nsim=1000,fix.n = T))
## Generating 1000 simulations of CSR with fixed number of points  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990......... 1000.
## 
## Done.

Preparar el archivo PPP para archivos equidistantes

En los siguientes diagramas se despliegan los modelos de densidad, KRipleys, KRipleys envelopes y L-transformation

p.equidistant<-ppp(equidistant$X, equidistant$Y, window=W1)
p2.equidistant<- as.ppp(p.equidistant)#remueve los puntos ilegales

plot(p2.equidistant) # Imprimir los puntos

DD.p2.equidistant <- density(p2.equidistant)
plot(DD.p2.equidistant) #Imprimir la desnisad

KK.p2.equidistant<- Kest(p2.equidistant)
plot(KK.p2.equidistant) #Realizar la prueba de Ripleys K-function

plot(envelope(p2.equidistant,Kest))
## Generating 99 simulations of CSR  ...
## 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, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
## 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
## 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,  99.
## 
## Done.

plot(envelope(p2.equidistant,Lest, nsim=1000,fix.n = T))
## Generating 1000 simulations of CSR with fixed number of points  ...
## 1, 2, 3, ......10.........20.........30.........40.........50.........60........
## .70.........80.........90.........100.........110.........120.........130......
## ...140.........150.........160.........170.........180.........190.........200....
## .....210.........220.........230.........240.........250.........260.........270..
## .......280.........290.........300.........310.........320.........330.........340
## .........350.........360.........370.........380.........390.........400........
## .410.........420.........430.........440.........450.........460.........470......
## ...480.........490.........500.........510.........520.........530.........540....
## .....550.........560.........570.........580.........590.........600.........610..
## .......620.........630.........640.........650.........660.........670.........680
## .........690.........700.........710.........720.........730.........740........
## .750.........760.........770.........780.........790.........800.........810......
## ...820.........830.........840.........850.........860.........870.........880....
## .....890.........900.........910.........920.........930.........940.........950..
## .......960.........970.........980.........990......... 1000.
## 
## Done.