library(leaflet.extras)
library(apcluster)
library(magrittr)
library(dplyr)
library(leaflet)
library(rgdal)
library(rgeos)
library(geojsonio)
library(mapview)
library(contoureR)
library(geosphere)
library(cluster)
library(sp)
library(rgdal)
library(RColorBrewer)
library(sp)
library(foreign)
anoscorte = 0
dados = read.dbf("/Users/fagne/OneDrive/r-files/CIET/acidentes2020/_Base/acidentes_2014a2020_WGS84.dbf")
dados = dados[dados$ANO > 2014, ]
table(dados$TIPO_ACID)
##
## ABALROAMENTO ATROPELAMENTO CAPOTAGEM CHOQUE COLISAO
## 36700 4514 256 6024 24419
## EVENTUAL INCENDIO NAO CADASTRADO QUEDA TOMBAMENTO
## 1038 23 4 1944 180
table(dados$FERIDOS)
##
## -1 0 1 2 3 4 5 6 7 8 9 19 21
## 1 50751 20508 3112 505 134 49 14 15 4 3 1 1
## 25 35
## 3 1
dados = dados[dados$TIPO_ACID == "ATROPELAMENTO", ]
sort(unique(dados$ANO))
## [1] 2015 2016 2017 2018 2019 2020
anos = length(unique(dados$ANO))
anos
## [1] 6
class(dados)
## [1] "data.frame"
x2 <- cbind(dados$LONGITUDE, dados$LATITUDE)
x2 <- x2[complete.cases(x2), ]
dim(x2)
## [1] 4514 2
head(x2)
## [,1] [,2]
## [1,] -51.06018 -30.23187
## [2,] -51.08561 -30.14308
## [3,] -51.08814 -30.15189
## [4,] -51.08883 -30.14002
## [5,] -51.08980 -30.23747
## [6,] -51.09070 -30.13943
# x1 <- x2
# #x2 <- x2[sample(nrow(x2), nrow(dados)), ]
# x2 = as.data.frame(x2)
# names(x2) = c("LONGITUDE", "LATITUDE" )
# head(x2)
# save(x2, file = "data/x2-atropelamentos-999.rda")
# dim(x1)
# dim(x2)
# apres <- apcluster(negDistMat(r=2), x2, q=.999)
# plot(apres, x2)
# summary(apres)
# save(apres, file = "data/apres2-atropelamentos-999.rda")
load("data/x2-atropelamentos-999.rda")
load("data/apres2-atropelamentos-999.rda")
centroides = unique(apres@exemplars)
poly = data.frame()
centr_indice = 0
for (i in centroides){
centr_indice = centr_indice + 1
centr_lat=x2[i,1]
centr_lon=x2[i,2]
poly = rbind(poly, c(centr_lat, centr_lon, centr_indice))
}
names(poly) = c("Lat", "Lon", "Cluster")
head(poly)
dim(poly)
## [1] 1997 3
exemplars = poly
save(exemplars, file = "data/exemplars-atropelamentos-999.rda")
dados$cluster = 0
controle = 0
for (i in 1:length(apres@exemplars)) {
a = unlist(apres@clusters[i])
if (length(a) >= anoscorte) {#atualizar anos
controle = controle + 1
for (item in 1:length(a)) {
dados$cluster[as.numeric(a[item])] = i
}
}
}
pal <- colorFactor(
palette = 'Dark2',
domain = dados$cluster
)
leaflet(dados) %>%
addTiles(group="Mapa") %>%
addCircles(group="Acidentes", ~LONGITUDE, ~LATITUDE, weight = 0.1, radius=7, color=~pal(cluster),
stroke = TRUE, fillOpacity = 0.8, popup=~paste("Cluster Nº: ", cluster,
"<br>Ano: ", ANO, "<br>Tipo: ", TIPO_ACID, "<br>Local: ", LOG1, "<br>UPS: ", UPS, sep = " ")) %>%
addLegend(group="Legenda", "topright", colors= "", labels=paste("Classificados em meio a ", summary(apres)[1], "Clusters"), title="Running over in Porto Alegre") %>%
addLayersControl(overlayGroups = c("Mapa", "Acidentes", "Legenda"),
options = layersControlOptions(collapsed = FALSE)) %>%
addProviderTiles(providers$CartoDB.DarkMatter)
A caption
#dados = dados[dados$cluster >0 ,]
#rm(apres)
clusters_encontrados = sort(unique(dados$cluster))
#clusters_encontrados
parq = dados
poly = data.frame()
for (i in clusters_encontrados){
temp = parq[parq$"cluster" == i, ]
ch1 = convexHullAM_Indexes(temp[,2],temp[,3], includeColinear=FALSE,zeroBased = FALSE)
#print(i)
#print(ch1)
poligono = temp[ch1, 2:3 ]
area <- geosphere::areaPolygon(x = poligono)
acidentes = nrow(temp)
pol = temp
coordinates(pol) = ~LONGITUDE+LATITUDE
centr_lat=gCentroid(pol, byid=FALSE)$x
centr_lon=gCentroid(pol, byid=FALSE)$y
if(nrow(temp) >= anoscorte) { #anos atualizar
for (ii in ch1) {
polying = temp[ii,]
polying$area = area
polying$acidentes = acidentes
polying$centroide_lat = centr_lat
polying$UPS = sum(temp$UPS)
polying$centroide_lon = centr_lon
poly = rbind(poly, polying)
}
}
}
head(poly)
tail(poly)
mean(poly$area)
## [1] 525.602
median(poly$area)
## [1] 58.76589
minimoquantil = quantile(poly$area, probs = 0.01)
maximoquantil = quantile(poly$area, probs = 0.99)
quantile(poly$area, probs = c(0.01, 0.25, 0.5,0.75,0.99))
## 1% 25% 50% 75% 99%
## 0.00000 0.00000 58.76589 363.48168 6420.23330
#poly = poly[(poly$area < maximoquantil) & (poly$area > minimoquantil), ]
dim(poly)
## [1] 4651 48
class(poly)
## [1] "data.frame"
pol = poly
resumo = poly[!duplicated(poly$cluster),]
summary(resumo$area)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.00 0.00 0.00 254.73 57.59 15458.66
summary(resumo$UPS)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.00 5.00 5.00 12.14 15.00 98.00
dados = poly[,c(1:9, 11:13,38,41,44:48)]
head(dados)
names(dados) = c("ID","lat", "lon", "log1", "Log2", "Pred", "Local", "Tipo", "Via", "Data", "Dia", "Hora",
"Fx_horaria","UPS", "box_id", "Area", "Acidentes", "CentLon", "CentLat")
dados$id = (dados$box_id * 11)
dados$group = dados$id
head(dados)
dadostemp = dados[, c(15:21)]
dadosplot = dados
coordinates(dados)=c("lat","lon")
df = dados
df
## class : SpatialPointsDataFrame
## features : 4651
## extent : -51.27422, -51.06018, -30.24154, -29.9684 (xmin, xmax, ymin, ymax)
## crs : NA
## variables : 19
## names : ID, log1, Log2, Pred, Local, Tipo, Via, Data, Dia, Hora, Fx_horaria, UPS, box_id, Area, Acidentes, ...
## min values : 601002, AC B VILA DO BARRACAO, AV ALBERTO BINS, 0, Cruzamento, ATROPELAMENTO, 0 AV NITEROI, 01/01/2015, DOMINGO, 00:00, 0, 1, 1, 0, 1, ...
## max values : 683118, TRAV SAO JOAO, VDT OBIRICI, 24108, Logradouro, ATROPELAMENTO, TRAV GERMANO GARCIA & AV OTTO NIEMEYER, 31/12/2015, TERCA-FEIRA, 23:59, 23, 98, 1997, 15458.6635937032, 18, ...
data <- data.frame(box_id=unique(df$box_id),row.names=unique(df$id))
head(data)
dadostemp2 = dados[!duplicated(dados$id),]
#head(dadostemp2, 15)
data = as.data.frame(cbind(data, dadostemp2@data))
dadosplot = dadosplot[order(dadosplot$UPS),]
pal <- colorFactor(
palette = 'Dark2',
domain = dadosplot$UPS
)
clusters = length(unique(dadosplot$UPS))
head(dadosplot)
dfs = as.data.frame(table(dadosplot$UPS))
head(dfs)
dadosplot$n = 0
for (i in dfs$Var1) {
dados <- within(dadosplot, n[UPS == i] <- as.numeric(dfs[dfs$Var1 == i, ][2]))
}
dadosplot <- dadosplot %>% mutate(Quartiles = ntile(n, 10))
pal <- colorNumeric(rev(c("#a50026", "#d73027", "#f46d43", "#fdae61", "#fee090",
"#ffffbf", "#abd9e9", "#74add1", "#4575b4", "#313695")), dados$Quartiles, n = 10)
pal <- colorFactor(
palette = 'YlOrRd',
domain = dadosplot$UPS
)
leaflet(dadosplot) %>%
addTiles(group="Mapa") %>%
addCircles(group="Acidentes", ~lat, ~lon, weight = 0.1, radius=7, color=~pal(UPS),
stroke = TRUE, fillOpacity = 0.8, popup=~paste("Cluster Nº: ", box_id,"<br>UPS: ", UPS,
"<br>Tipo: ", Tipo, "<br>Local: ", log1, sep = " ")) %>%
addLegend(group="Legenda", "bottomleft", colors= "", labels=paste("Classified into ", clusters, "Clusters"), title="Running over in Porto Alegre") %>%
#addLayersControl(overlayGroups = c("Mapa", "Acidentes", "Legenda"), options = layersControlOptions(collapsed = FALSE)) %>%
addProviderTiles(providers$CartoDB.Positron)%>%
addLegend(pal = (pal), values = ~UPS, opacity = 1, labels="UPS Quantiles")
A caption
dadosplot$densidade = round(dadosplot$Acidentes/dadosplot$Area, 3)
dadosplot = dadosplot[order(dadosplot$densidade),]
pal <- colorFactor(
palette = 'Dark2',
domain = dadosplot$densidade
)
clusters = length(unique(dadosplot$densidade))
head(dadosplot)
dfs = as.data.frame(table(dadosplot$densidade))
head(dfs)
dadosplot$n = 0
for (i in dfs$Var1) {
dados <- within(dadosplot, n[densidade == i] <- as.numeric(dfs[dfs$Var1 == i, ][2]))
}
dadosplot <- dadosplot %>% mutate(Quartiles = ntile(n, 10))
pal <- colorNumeric(rev(c("#a50026", "#d73027", "#f46d43", "#fdae61", "#fee090",
"#ffffbf", "#abd9e9", "#74add1", "#4575b4", "#313695")), dados$Quartiles, n = 10)
leaflet(dadosplot) %>%
addTiles(group="Mapa") %>%
addCircles(group="Acidentes", ~lat, ~lon, weight = 0.1, radius=7, color=~pal(Quartiles),
stroke = TRUE, fillOpacity = 0.8, popup=~paste("Cluster Nº: ", box_id,"<br>UPS: ", UPS,"<br>Densidade: ", densidade,
"<br>Tipo: ", Tipo, "<br>Local: ", log1, sep = " ")) %>%
addLegend(group="Legenda", "bottomleft", colors= "", labels=paste("Classified into ", clusters, "Clusters"), title="Running over in Porto Alegre") %>%
#addLayersControl(overlayGroups = c("Mapa", "Acidentes", "Legenda"), options = layersControlOptions(collapsed = FALSE)) %>%
addProviderTiles(providers$CartoDB.Positron)%>%
addLegend(pal = (pal), values = ~Quartiles, opacity = 1, labels="Accident Quantiles")
A caption
points2polygons <- function(df,data) {
get.grpPoly <- function(group,ID,df) {
Polygon(coordinates(df[df$id==ID & df$group==group,]))
}
get.spPoly <- function(ID,df) {
Polygons(lapply(unique(df[df$id==ID,]$group),get.grpPoly,ID,df),ID)
}
spPolygons <- SpatialPolygons(lapply(unique(df$id),get.spPoly,df))
SpatialPolygonsDataFrame(spPolygons,match.ID=T,data=data)
}
#Criamos o SpatialPolygonsDataFrame
data$Log2 = NULL
spDF <- points2polygons(df,data)
spDF
## class : SpatialPolygonsDataFrame
## features : 1997
## extent : -51.27422, -51.06018, -30.24154, -29.9684 (xmin, xmax, ymin, ymax)
## crs : NA
## variables : 19
## names : box_id, ID, log1, Pred, Local, Tipo, Via, Data, Dia, Hora, Fx_horaria, UPS, box_id.1, Area, Acidentes, ...
## min values : 1, 601042, AC B VILA DO BARRACAO, 0, Cruzamento, ATROPELAMENTO, 10 AV BORGES DE MEDEIROS, 01/01/2015, DOMINGO, 00:00, 0, 1, 1, 0, 1, ...
## max values : 1997, 683118, TRAV SAO JOAO, 24108, Logradouro, ATROPELAMENTO, TRAV CAMERUM & AV BENNO MENTZ, 31/10/2019, TERCA-FEIRA, 23:59, 23, 98, 1997, 15458.6635937032, 18, ...
class(spDF)
## [1] "SpatialPolygonsDataFrame"
## attr(,"package")
## [1] "sp"
spDF@data$group = 1
spDF@data$box_id = NULL
dim(spDF@data)
## [1] 1997 18
dadostemp = unique(dadostemp)
spDF@data = merge(spDF@data, dadostemp, by = "box_id")
dim(spDF@data)
## [1] 1997 24
spDF$log1 = spDF$Pred = spDF$CentLon.x = spDF$CentLat.x = spDF$CentLon.y = spDF$CentLat.y = spDF$id.y = spDF$group.y = spDF$Tipo = spDF$Via = spDF$Tipo = spDF$Dia = spDF$Data= spDF$group.x = spDF$Local= spDF$Hora= spDF$Area.x= spDF$Fx_horaria = NULL
plot(spDF,col=spDF$box_id+1)
A caption
library(rgdal)
rgdal::writeOGR(obj = spDF,
dsn = "data/atropelamenos.json",
layer = "myParq",
driver = "GeoJSON",
overwrite_layer = TRUE)
Acidentes por Cluster
#carregamos os dados SpatialPolygonsDataFrame
parqs <- geojsonio::geojson_read("data/atropelamenos.json", what = "sp")
#Verificamos o objeto
parqs
## class : SpatialPolygonsDataFrame
## features : 1997
## extent : -51.27422, -51.06018, -30.24154, -29.9684 (xmin, xmax, ymin, ymax)
## crs : +proj=longlat +datum=WGS84 +no_defs
## variables : 7
## names : box_id, ID, UPS, Acidentes.x, id.x, Area.y, Acidentes.y
## min values : 1, 601042, 1, 1, 11, 0, 1
## max values : 1997, 683118, 98, 18, 21967, 15458.6635937032, 18
dim(parqs)
## [1] 1997 7
library(raster)
projection(parqs)
## [1] "+proj=longlat +datum=WGS84 +no_defs"
library(mapview)
mapviewPalette(name = "Viridis")
library(RColorBrewer)
mapview(parqs, zcol = "Acidentes.x", col.regions=brewer.pal(9, "YlOrRd"))
Acidentes por m2
parqs@data$Area.y = ifelse(parqs@data$Area.y== 0, 1, parqs@data$Area.y)
parqs@data$densidade = (parqs@data$Acidentes.x/parqs@data$Area.y)*1000000
parqs@data$densidade = ifelse(is.infinite(parqs@data$densidade), max(is.infinite(parqs@data$densidade))*2,parqs@data$densidade)
mapview(parqs, zcol = "densidade", col.regions=brewer.pal(9, "YlOrRd"))
Acidentes por poligono
hist(parqs@data$Acidentes.x, col = "magenta")
A caption
Acidentes por KM2
hist(parqs@data$densidade, col = "orange")
A caption
Locais mais densos
quantile(parqs$densidade, probs = 0.99)
## 99%
## 4e+06
temp = parqs[parqs$densidade > quantile(parqs$densidade, probs = 0.001), ] # Atualziar
mapview(temp, zcol = "densidade")
projection(parqs)
## [1] "+proj=longlat +datum=WGS84 +no_defs"
parqstemp = parqs
require(sf)
shape <- read_sf(dsn = ".", layer = "mercator_32722_2014_2019")
projection(shape)
## [1] "+proj=utm +zone=22 +south +datum=WGS84 +units=m +no_defs"
projection(parqstemp) = projection(shape)
ccods = coordinates(parqs)
temps = as.data.frame(ccods)
cord.dec = SpatialPoints(cbind(temps$V1, temps$V2), proj4string=CRS("+proj=longlat"))
cord.UTM <- spTransform(cord.dec, CRS("+init=epsg:32722"))
ccods = as.data.frame(cord.UTM)
points = cbind(ccods[,1],ccods[,2])
head(points)
## [,1] [,2]
## [1,] 494209.3 6655520
## [2,] 491755.2 6665357
## [3,] 491511.9 6664381
## [4,] 491444.5 6665696
## [5,] 491359.6 6654897
## [6,] 491264.4 6665761
library(spdep)
distNeighbors = 400
dnb = dnearneigh(points,0,distNeighbors)
class(dnb)
## [1] "nb"
subsets = as.data.frame(matrix(dnb))
class(subsets)
## [1] "data.frame"
subsets = subsets$V1
lengths(subsets)
## [1] 1 1 1 1 1 1 3 3 1 1 2 1 4 4 3 4 3 3 3 3 2 3 3 4
## [25] 1 4 3 2 5 4 4 2 6 7 2 7 3 3 1 6 2 7 3 6 6 4 7 3
## [49] 3 8 8 8 3 2 9 1 7 4 7 5 8 1 8 8 2 7 5 6 6 4 9 9
## [73] 4 9 8 3 6 6 3 3 6 5 6 4 8 4 4 7 1 8 5 4 1 4 7 5
## [97] 8 8 10 2 5 4 3 4 4 5 4 9 8 5 5 3 3 4 2 7 10 1 1 3
## [121] 8 9 11 6 3 3 3 4 8 1 6 2 7 3 10 6 12 4 1 4 2 3 9 9
## [145] 3 4 4 5 11 5 12 5 3 13 12 1 4 6 6 5 3 13 5 8 13 3 1 5
## [169] 12 3 4 1 11 6 5 1 3 4 4 4 7 5 10 1 7 1 3 4 4 1 8 1
## [193] 3 6 5 1 9 5 4 7 2 1 5 7 5 5 5 4 1 6 4 1 5 6 3 3
## [217] 2 4 6 3 5 6 5 3 6 1 4 3 6 5 3 3 4 4 8 5 6 6 7 7
## [241] 5 3 1 2 3 4 3 2 3 2 3 1 5 2 2 8 5 1 1 3 2 6 4 3
## [265] 6 3 2 6 3 4 6 6 4 5 1 2 4 1 11 5 2 4 4 1 3 8 5 2
## [289] 1 1 6 3 4 1 2 1 1 4 1 6 5 2 5 2 1 3 6 6 7 1 7 8
## [313] 7 5 5 5 5 1 5 1 7 4 7 5 2 4 1 5 1 8 8 10 2 1 4 5
## [337] 3 6 3 6 5 2 3 3 9 6 5 2 4 2 4 5 8 8 3 1 1 5 1 5
## [361] 5 7 3 1 6 3 3 6 5 3 2 3 4 5 5 7 6 5 2 7 7 8 6 2
## [385] 2 7 9 2 8 6 7 1 3 2 7 8 8 8 4 9 3 9 1 8 6 10 4 3
## [409] 4 9 5 7 6 10 7 5 5 1 2 5 2 4 1 5 3 5 4 1 7 11 4 9
## [433] 3 2 7 8 6 4 3 5 5 1 2 5 8 1 4 10 10 3 3 9 3 3 8 6
## [457] 11 4 6 4 1 9 9 5 1 3 10 1 3 7 5 7 7 10 9 1 4 5 2 4
## [481] 3 5 2 7 10 1 2 12 5 1 4 1 4 4 7 2 5 9 12 4 5 5 14 5
## [505] 11 13 7 4 1 3 7 12 5 1 13 7 5 8 13 2 3 5 1 11 6 6 12 4
## [529] 9 1 3 13 6 3 3 4 12 4 10 1 6 7 4 3 4 8 12 7 2 2 5 4
## [553] 10 4 1 2 7 11 4 4 2 8 2 3 1 1 3 4 6 8 1 2 5 1 2 1
## [577] 2 2 7 3 1 5 3 8 1 4 6 6 4 8 9 2 8 3 6 3 8 6 3 5
## [601] 3 7 8 4 9 9 4 4 4 5 7 6 6 1 2 9 8 3 8 5 4 6 3 10
## [625] 1 1 3 4 2 8 9 5 3 9 8 8 10 1 3 9 13 3 2 5 5 2 7 4
## [649] 2 3 8 4 12 6 2 2 1 13 10 3 7 4 2 8 12 9 3 2 8 5 11 8
## [673] 8 12 4 9 7 10 7 5 7 9 13 6 12 8 6 7 6 10 8 5 8 6 4 8
## [697] 5 5 10 11 10 5 6 9 6 8 2 5 6 8 9 1 10 6 8 1 11 3 3 8
## [721] 11 7 4 10 2 6 9 6 8 8 9 1 4 4 9 8 7 5 10 1 10 9 5 9
## [745] 9 7 5 4 10 5 4 7 9 10 2 6 5 5 5 6 5 6 10 8 5 4 8 9
## [769] 4 3 1 7 8 12 8 7 4 5 4 11 2 7 7 3 5 6 5 8 5 9 12 8
## [793] 7 10 5 1 8 7 3 6 10 11 7 10 7 9 9 3 10 7 6 11 3 10 2 4
## [817] 9 9 4 5 5 4 11 6 4 10 1 12 12 7 13 4 10 8 4 3 10 4 11 14
## [841] 6 3 7 11 11 11 4 6 9 6 9 12 5 9 13 10 6 2 6 3 12 11 5 10
## [865] 15 12 4 8 10 13 8 2 13 1 11 4 7 13 10 7 3 6 11 10 7 10 11 12
## [889] 8 8 8 11 9 3 1 8 7 3 10 4 5 7 10 7 9 2 6 9 8 14 4 10
## [913] 10 12 10 8 2 13 11 7 12 8 3 9 1 4 12 3 9 10 9 6 6 11 2 13
## [937] 13 9 3 7 7 8 4 3 13 9 7 11 15 12 4 10 4 5 6 14 5 7 10 11
## [961] 8 5 10 5 1 6 11 4 10 16 11 4 12 3 9 9 16 17 17 10 19 9 2 8
## [985] 13 8 12 1 5 3 18 1 14 8 7 1 16 19 18 21 6 14 20 19 8 13 22 6
## [1009] 8 15 12 13 15 20 20 12 11 11 16 6 19 18 15 25 25 14 5 8 7 14 16 5
## [1033] 13 21 6 5 18 14 9 17 3 14 11 14 5 5 14 19 16 14 13 4 5 15 10 18
## [1057] 18 13 15 20 13 15 13 7 9 18 16 10 17 10 12 5 12 3 16 9 9 17 3 6
## [1081] 15 5 10 13 5 1 14 18 15 8 15 19 10 11 5 14 7 12 4 18 12 18 11 17
## [1105] 7 3 14 8 4 17 1 3 6 6 15 11 21 7 20 4 6 17 7 3 19 12 10 5
## [1129] 19 6 8 2 10 19 4 4 11 10 3 12 11 6 13 16 14 6 11 14 7 3 17 11
## [1153] 1 3 4 2 5 18 13 1 5 7 4 21 5 15 19 18 4 20 5 9 6 15 3 6
## [1177] 23 7 15 12 6 21 4 11 12 4 17 15 5 4 10 10 6 15 1 25 13 4 6 25
## [1201] 15 27 5 18 3 9 6 4 26 18 11 23 20 11 3 4 25 12 10 6 1 5 2 2
## [1225] 4 1 8 29 1 13 26 24 20 5 7 7 4 3 17 4 7 15 5 5 23 5 26 13
## [1249] 13 13 8 27 7 5 7 1 22 5 19 13 9 27 7 3 13 25 7 17 4 13 27 15
## [1273] 11 6 11 8 23 26 29 11 9 16 6 9 26 3 13 13 6 14 17 10 12 7 2 5
## [1297] 6 8 6 4 11 5 1 12 27 20 12 11 11 7 16 7 18 8 8 22 9 22 8 11
## [1321] 22 8 5 4 11 4 11 3 6 16 8 16 9 11 10 7 7 12 14 9 13 2 21 2
## [1345] 11 12 10 3 10 6 15 1 9 7 2 5 16 6 2 5 2 1 15 13 10 9 6 12
## [1369] 9 10 16 12 10 5 8 8 7 12 6 9 5 14 8 9 5 7 11 3 9 1 5 10
## [1393] 9 7 10 5 1 8 5 4 4 1 6 6 6 6 5 3 7 1 6 1 2 1 5 4
## [1417] 4 6 4 4 6 5 3 1 1 2 2 2 2 3 3 1 1 1 4 2 3 5 5 3
## [1441] 5 4 4 1 1 1 7 5 6 4 2 1 17 4 1 6 7 8 2 1 3 8 8 9
## [1465] 9 7 8 5 10 7 2 2 1 4 10 16 10 5 8 11 8 5 4 9 6 9 8 15
## [1489] 4 9 8 9 5 8 17 5 5 18 6 12 6 10 9 1 13 14 5 1 1 4 5 3
## [1513] 10 9 9 9 4 1 1 6 5 4 1 1 1 3 2 2 4 1 8 16 1 4 4 1
## [1537] 9 2 2 5 1 8 7 7 2 4 3 6 5 23 19 4 1 1 6 5 2 9 9 3
## [1561] 9 4 17 8 8 14 9 2 6 4 5 6 8 16 17 14 8 11 2 10 2 1 1 5
## [1585] 1 3 2 9 15 7 8 4 5 10 14 3 3 6 12 1 6 6 2 2 2 6 7 19
## [1609] 13 21 10 6 4 8 5 4 3 8 8 3 19 17 20 4 1 5 7 5 31 10 9 5
## [1633] 5 4 7 7 9 6 3 3 3 6 2 17 16 11 6 5 9 4 2 5 2 8 14 6
## [1657] 12 12 13 7 3 8 10 18 3 4 16 23 8 4 6 4 6 6 4 6 6 2 6 7
## [1681] 4 4 5 9 8 11 24 2 5 18 19 18 3 3 1 2 10 10 9 1 6 29 6 8
## [1705] 4 7 4 6 10 3 6 4 4 8 9 4 5 10 22 1 27 1 25 3 5 5 5 4
## [1729] 3 12 17 5 14 14 10 7 2 4 4 7 11 6 6 5 7 4 4 3 5 3 1 1
## [1753] 3 2 10 20 1 7 5 5 1 1 11 9 9 3 3 5 3 6 7 7 3 1 11 3
## [1777] 1 5 6 14 25 5 6 11 5 1 19 10 9 15 23 1 1 10 6 7 7 2 6 2
## [1801] 3 4 4 4 5 4 5 5 2 7 6 9 12 5 1 1 4 3 3 27 11 9 13 6
## [1825] 4 18 8 8 1 11 8 26 5 11 5 9 2 3 4 2 8 5 19 3 6 6 31 11
## [1849] 4 9 12 5 5 5 8 3 6 7 5 8 13 4 3 5 5 6 3 5 2 5 17 10
## [1873] 5 8 14 3 3 14 5 11 8 7 2 7 17 23 2 7 12 2 4 8 6 6 24 7
## [1897] 7 13 4 13 1 17 5 2 9 4 3 7 2 4 10 7 5 8 6 7 4 4 13 1
## [1921] 7 4 1 5 3 1 6 7 2 8 9 6 3 5 3 7 2 4 9 5 6 15 5 6
## [1945] 3 3 2 5 6 10 3 1 8 1 3 7 9 8 5 4 4 11 7 4 1 3 3 4
## [1969] 10 21 7 5 8 6 7 5 4 10 12 4 6 5 4 14 2 8 10 7 13 13 6 1
## [1993] 1 9 1 1 1
parqs$n = 1
sub = which(subsets == '0')
sub
## [1] 1 2 3 5 9 89 93 119 130 156 167 176 186 192 196
## [16] 209 226 252 258 259 284 290 294 296 305 310 318 320 357 364
## [31] 403 423 442 476 509 530 540 555 566 581 638 657 712 740 771
## [46] 796 895 965 988 996 1226 1229 1303 1352 1412 1433 1444 1446 1455 1460
## [61] 1504 1518 1536 1553 1582 1625 1695 1751 1752 1757 1777 1829 1901 1920 1923
## [76] 1926 1954 1965 1992 1993 1995
parqs$n[sub] = 0
length(parqs)
## [1] 1997
parqs = parqs[parqs$n > 0,]
length(parqs)
## [1] 1916
length(dnb)
## [1] 1997
#dim(ccods)
ccods = ccods[-sub, ]
dim(ccods)
## [1] 1916 2
points = cbind(ccods[,1],ccods[,2])
head(points)
## [,1] [,2]
## [1,] 491444.5 6665696
## [2,] 491264.4 6665761
## [3,] 491250.8 6680878
## [4,] 491249.7 6680562
## [5,] 491218.8 6678609
## [6,] 491176.7 6678722
#dnb = dnearneigh(points,0,2000)
dnb = dnearneigh(points,0,distNeighbors)
dnb
## Neighbour list object:
## Number of regions: 1916
## Number of nonzero links: 13960
## Percentage nonzero weights: 0.3802721
## Average number of links: 7.286013
length(dnb)
## [1] 1916
W.Bin= nb2mat(neighbours = dnb, style = "B")
#parqs <- parqs[!sub,]
W.Normal= nb2mat(neighbours = dnb, style = "W")
#head(W.Normal)
vizinhos_4 <- knearneigh(points, k = 4)
class(vizinhos_4)
## [1] "knn"
head(vizinhos_4$nn)
## [,1] [,2] [,3] [,4]
## [1,] 2 13 14 21
## [2,] 1 13 14 21
## [3,] 4 12 8 29
## [4,] 8 3 10 12
## [5,] 6 26 16 40
## [6,] 5 16 26 40
vizinhanca_4 <- knn2nb(vizinhos_4)
class(vizinhanca_4)
## [1] "nb"
Preparação para Análisis Global e Local
mv_simpl = st_as_sf(parqs)
plot(mv_simpl)
A caption
class(mv_simpl)
## [1] "sf" "data.frame"
library(dplyr)
mv_simpl = mv_simpl %>% dplyr::select(Acidentes.y)
#mv_simpl <- st_simplify(mv_simpl, preserveTopology = FALSE, dTolerance = 1)
class(mv_simpl)
## [1] "sf" "data.frame"
mapview::mapview(mv_simpl)
sf::sf_use_s2(FALSE)#trips and tiks
## Spherical geometry (s2) switched off
mv_simpl = st_as_sf(mv_simpl)
vizinhanca_neig <- poly2nb(mv_simpl)
ShapeNEIG = parqs
ShapeNEIG$vizinhos = card(vizinhanca_neig)
ShapeNEIG <- subset(ShapeNEIG, parqs$vizinhos != 0)
#vizinhanca2neig <- poly2nb(ShapeNEIG)
Os índices de autocorrelção espacial global calculados pelos testes de normalidade e permutação.
moran.test(parqs$Acidentes.y,listw=nb2listw(dnb, style = "W"), randomisation= FALSE)
##
## Moran I test under normality
##
## data: parqs$Acidentes.y
## weights: nb2listw(dnb, style = "W")
##
## Moran I statistic standard deviate = 15.384, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.2327230669 -0.0005221932 0.0002298601
moran.test(parqs$Acidentes.y,listw=nb2listw(dnb, style = "W"), randomisation= TRUE)
##
## Moran I test under randomisation
##
## data: parqs$Acidentes.y
## weights: nb2listw(dnb, style = "W")
##
## Moran I statistic standard deviate = 15.412, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.2327230669 -0.0005221932 0.0002290270
moran.mc(parqs$Acidentes.y, listw=nb2listw(dnb, style = "W"), nsim=999)
##
## Monte-Carlo simulation of Moran I
##
## data: parqs$Acidentes.y
## weights: nb2listw(dnb, style = "W")
## number of simulations + 1: 1000
##
## statistic = 0.23272, observed rank = 1000, p-value = 0.001
## alternative hypothesis: greater
Diferente dos demais testes globais o teste para o EBI é exclusivo para taxas e tem-se apenas a opção de teste da permutação
EBImoran.mc(parqs$Acidentes.y,parqs$Area.y,
nb2listw(dnb, style="B", zero.policy=TRUE), nsim=999, zero.policy=TRUE)
##
## Monte-Carlo simulation of Empirical Bayes Index (mean subtracted)
##
## data: cases: parqs$Acidentes.y, risk population: parqs$Area.y
## weights: nb2listw(dnb, style = "B", zero.policy = TRUE)
## number of simulations + 1: 1000
##
## statistic = -0.002523, observed rank = 218, p-value = 0.782
## alternative hypothesis: greater
shapeCG.p=parqs$Acidentes.y/parqs$Area.y
moran.mc(shapeCG.p, nb2listw(dnb, style="B", zero.policy=TRUE),
nsim=999, zero.policy=TRUE)
##
## Monte-Carlo simulation of Moran I
##
## data: shapeCG.p
## weights: nb2listw(dnb, style = "B", zero.policy = TRUE)
## number of simulations + 1: 1000
##
## statistic = -0.0012042, observed rank = 344, p-value = 0.656
## alternative hypothesis: greater
geary.test(parqs$Acidentes.y, listw=nb2listw(dnb, style = "W"), randomisation= FALSE)
##
## Geary C test under normality
##
## data: parqs$Acidentes.y
## weights: nb2listw(dnb, style = "W")
##
## Geary C statistic standard deviate = 14.151, p-value < 2.2e-16
## alternative hypothesis: Expectation greater than statistic
## sample estimates:
## Geary C statistic Expectation Variance
## 0.7771204829 1.0000000000 0.0002480809
geary.test(parqs$Acidentes.y, listw=nb2listw(dnb, style = "W"), randomisation=TRUE)
##
## Geary C test under randomisation
##
## data: parqs$Acidentes.y
## weights: nb2listw(dnb, style = "W")
##
## Geary C statistic standard deviate = 12.632, p-value < 2.2e-16
## alternative hypothesis: Expectation greater than statistic
## sample estimates:
## Geary C statistic Expectation Variance
## 0.7771204829 1.0000000000 0.0003112911
geary.mc(parqs$Acidentes.y, listw=nb2listw(dnb, style = "W"),nsim=999)
##
## Monte-Carlo simulation of Geary C
##
## data: parqs$Acidentes.y
## weights: nb2listw(dnb, style = "W")
## number of simulations + 1: 1000
##
## statistic = 0.77712, observed rank = 1, p-value = 0.001
## alternative hypothesis: greater
Getis-Ord é um indicador que mede a concentração local de uma variável de atributo distribuída espacialmente
globalG.test(parqs$Acidentes.y, nb2listw(dnb, style="B"))
##
## Getis-Ord global G statistic
##
## data: parqs$Acidentes.y
## weights: nb2listw(dnb, style = "B")
##
## standard deviate = 27.349, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Global G statistic Expectation Variance
## 6.848907e-03 3.804706e-03 1.238964e-08
localG(parqs$Acidentes.y, nb2listw(dnb, style="B"), zero.policy=NULL, spChk=NULL, return_internals=FALSE)
## [1] -0.149944552 -0.642995490 -1.114843481 -1.114843481 -0.643318808
## [6] -0.212109036 -0.149944552 -1.287647140 -1.286999997 -0.829844780
## [11] -0.546433592 -1.114843481 -0.829844780 -0.829844780 -0.829844780
## [16] -0.560296379 -0.543911183 0.026042259 -0.547005087 0.343429704
## [21] -1.286999997 -1.114283186 -0.909228921 -1.219135491 0.440517649
## [26] -0.546433592 -0.910027944 0.237280077 -1.144422932 -0.910027944
## [31] -1.517964762 -0.259847379 -0.829844780 0.343429704 -0.365900079
## [36] 0.136850418 -0.770881102 -1.114843481 -0.972085521 -1.174499522
## [41] -1.039654915 -0.768052251 -1.114843481 -0.829844780 -1.298654879
## [46] -1.472528414 -1.298654879 -0.829844780 -0.910027944 -0.285973843
## [51] 0.343652237 -1.144422932 -0.547005087 -1.143623399 -1.440010086
## [56] -1.298654879 -0.643318808 -1.298654879 -1.822000705 -0.910027944
## [61] -1.702815374 -0.998260896 -1.174499522 -1.174499522 -1.287647140
## [66] -1.109988151 -0.945185289 -0.793885771 -1.109988151 -1.123056124
## [71] -0.544846080 -0.771133922 -0.771133922 -0.829313594 -1.114843481
## [76] -0.569451122 -0.998260896 -0.971477986 -0.547005087 0.623639059
## [81] -1.039654915 -1.040766456 -0.955675624 -0.599638902 -0.335637112
## [86] 0.440517649 -0.793289061 -0.583367884 -1.217888167 -0.421555623
## [91] -0.599638902 0.463804714 -0.909570584 0.547861266 -1.039072111
## [96] 1.166573123 -0.793885771 -1.286516559 -0.554823272 0.194132812
## [101] -0.119612695 0.274131070 -0.114762518 -0.555878229 -0.259847379
## [106] -0.259847379 -1.286196668 -0.910027944 0.723286216 0.307433935
## [111] -0.643318808 -0.259847379 -0.599638902 -0.117387696 0.247126279
## [116] -1.172691848 -0.259847379 -1.113587664 -0.259847379 -0.793885771
## [121] 0.973147047 -0.971477986 -0.910027944 -0.770881102 -1.114283186
## [126] -0.470995432 -0.367768322 0.050421452 -1.287647140 -0.643318808
## [131] -0.300124403 -0.910027944 -0.259847379 -0.780382428 -0.780382428
## [136] -0.258934462 -0.545499008 -1.040766456 -0.998260896 0.097978210
## [141] -1.440010086 0.621765129 -0.776730264 0.310150022 0.418543128
## [146] -0.235250386 -1.286999997 -1.576479724 -0.972816722 -1.219135491
## [151] -0.828887905 -0.127744452 -1.440010086 -0.947613719 -0.540430178
## [156] -1.114843481 -0.998260896 -0.090617367 0.310150022 -0.299578124
## [161] 0.343918452 0.549043963 -0.972816722 0.107257197 -0.828887905
## [166] -0.052722656 -1.039654915 0.687398333 0.351082736 -0.113600364
## [171] 1.244969212 0.836803960 0.349744387 -1.113864626 -0.546433592
## [176] -0.547005087 0.343429704 1.149272488 -0.829844780 0.038786327
## [181] -0.335637112 2.186069081 -0.776730264 -1.286999997 2.220971755
## [186] -0.909570584 -0.149944552 -0.997030607 1.847297453 -0.556511707
## [191] 0.768735861 -1.438387984 -0.547005087 -0.568761120 -1.040766456
## [196] -0.643318808 -0.555315485 -0.568761120 -0.544344003 -0.259847379
## [201] -0.910027944 1.428040385 2.258987361 -0.258527369 -0.777386302
## [206] 1.851185285 -1.219135491 -1.114283186 0.035597277 -0.547005087
## [211] 0.595148723 0.845155714 3.860980185 -0.829844780 -0.829844780
## [216] -0.052208337 1.674921069 -0.067745361 2.756607212 1.850742476
## [221] -1.375409921 2.777766280 2.777766280 -0.997582299 -0.544846080
## [226] -0.643318808 0.137568704 0.025595180 -1.040766456 -1.114843481
## [231] 0.485809871 0.595148723 0.485809871 -0.543252778 -0.777386302
## [236] 0.487440470 -0.211363837 -0.243980257 -0.111446730 -1.113452323
## [241] -0.561068490 -1.174499522 3.403854685 -0.829844780 0.842328477
## [246] -0.829844780 1.184366330 -0.972816722 -1.114283186 3.896847225
## [251] 0.640645677 -0.972816722 -1.040144529 -1.439286369 -0.643318808
## [256] -0.909228921 1.674921069 -0.642995490 -0.647762138 -0.775354392
## [261] -0.561068490 0.200489988 -1.286999997 -0.829844780 1.497409031
## [266] -1.219135491 0.485809871 -0.149944552 -1.577865122 0.596532927
## [271] -1.040766456 -0.909570584 4.783798008 0.194132812 0.343429704
## [276] -0.771133922 0.327529911 -0.212109036 -0.556511707 -0.909228921
## [281] -0.829313594 0.846132158 -0.166085522 -1.515832366 1.843911705
## [286] -0.599638902 1.657654177 -0.335637112 -0.335637112 -0.997582299
## [291] -0.997582299 0.989610455 1.098108780 0.444187196 1.471621802
## [296] 0.326986671 -0.910027944 -0.793885771 -0.149417754 -0.998260896
## [301] 0.345423048 -0.074639252 0.099377076 1.089287832 0.486124663
## [306] 0.343918452 -1.287647140 -0.998260896 -0.259374411 0.237280077
## [311] 0.025151321 -1.577865122 -0.335637112 0.137568704 -0.543911183
## [316] -0.543252778 -0.780382428 -0.566393506 -0.114174159 -0.910027944
## [321] -1.287647140 -0.910027944 1.675823174 -0.554050024 2.720686991
## [326] 2.720686991 -1.114843481 0.836976101 -0.775354392 -0.643318808
## [331] 0.547861266 0.547861266 0.723286216 -1.114843481 0.842874283
## [336] 1.450925865 0.026042259 1.447376877 -0.556511707 0.027404550
## [341] -0.212109036 -0.259847379 -0.053243719 -0.335637112 1.652234239
## [346] 1.843911705 -0.166085522 3.419230996 1.532688233 2.964537195
## [351] 2.594646058 -1.473408874 0.035597277 -0.910027944 -0.909002841
## [356] 1.659313504 1.698508236 0.137954120 -1.122354236 1.059213857
## [361] -0.770881102 -0.643318808 0.880147423 -0.212109036 -0.023112369
## [366] 3.943964952 -1.473408874 -1.473408874 -1.039654915 -1.932304366
## [371] -1.114843481 -1.604396735 3.778486555 2.660944636 -1.726379085
## [376] -1.287647140 -1.114843481 4.149465278 3.855200604 -0.555315485
## [381] 2.404224450 1.450418688 2.655099239 -1.331193847 -0.998260896
## [386] -0.998260896 -0.643318808 -0.211363837 0.547861266 -0.561068490
## [391] 0.687398333 -0.997582299 -0.829844780 -0.114762518 -1.287647140
## [396] -0.643318808 3.907550604 1.143639942 -1.287647140 2.845764367
## [401] -1.114283186 -0.211363837 0.349744387 1.152428598 3.665887675
## [406] -1.287647140 -0.544846080 -1.440010086 -0.335637112 -0.561068490
## [411] -0.335026194 1.847458347 -0.643318808 -0.053243719 2.029505263
## [416] 1.244969212 0.025595180 -0.829844780 0.543391656 -0.829313594
## [421] 0.310150022 -0.424884907 0.441647065 1.742651671 -0.792103873
## [426] 1.045194473 -0.300124403 -0.643318808 1.198708520 2.358574853
## [431] 2.536050260 -0.643318808 -0.543911183 1.566525791 -0.643318808
## [436] -0.829844780 -0.956871561 1.874979686 -0.770881102 -0.584110187
## [441] 2.026902975 3.014250105 -0.053243719 0.106677876 -0.560296379
## [446] -0.547005087 -0.259847379 -1.439286369 -0.211722960 2.030682620
## [451] 3.747591083 -0.149671627 -0.561068490 2.052963614 1.874979686
## [456] -0.643318808 -0.793885771 -0.149671627 -0.791910263 -0.793885771
## [461] -1.329725862 -0.561068490 -0.335026194 -1.109988151 1.627330725
## [466] -0.793885771 -0.998260896 1.214292969 2.094112318 2.314858023
## [471] 1.591049643 3.164519392 -0.957652017 1.675265621 -1.114843481
## [476] -0.957652017 3.483298614 0.548972318 -0.643318808 2.889374028
## [481] 0.723286216 1.879003414 1.673494039 3.166944096 -0.910027944
## [486] -0.829844780 2.535732618 -0.642516042 2.186051184 0.640645677
## [491] -1.173747721 2.195810257 -0.052722656 1.860220954 -1.114843481
## [496] 1.524256082 -0.972816722 -0.829844780 0.885005196 -0.793289061
## [501] 1.339999996 -0.300124403 -0.162511560 -1.173145232 -1.331193847
## [506] -1.287647140 0.595148723 0.690502399 -1.473408874 0.621765129
## [511] -0.957652017 -0.910027944 -0.561068490 0.990086016 -0.300124403
## [516] 1.245658611 -1.039297448 -0.910027944 -0.957652017 -1.093408565
## [521] -0.053243719 -0.053243719 -0.560646772 -0.073192285 -0.910027944
## [526] -0.829313594 -0.643318808 -0.829844780 -0.052722656 -0.569451122
## [531] -0.424111542 -0.643318808 -0.561068490 -0.775354392 0.343429704
## [536] -0.910027944 -0.643318808 -0.910027944 -0.910027944 -0.395943308
## [541] -1.114843481 -0.998260896 0.595148723 0.099377076 -0.643318808
## [546] -0.793885771 -0.367768322 -1.174499522 -1.287647140 0.099377076
## [551] 1.033118049 -0.910027944 -0.424884907 -0.544846080 -0.970395961
## [556] -0.829313594 -0.073911133 -1.577865122 -1.114843481 -1.440010086
## [561] -1.114843481 -0.584110187 -1.123900885 -1.286516559 2.021834222
## [566] 1.530498340 -0.793885771 -1.040766456 -1.040766456 -0.556511707
## [571] 2.964537195 0.438962877 -0.771133922 -0.643318808 -0.910027944
## [576] 1.203458273 -0.250130913 -0.829844780 0.274131070 -0.996307317
## [581] -0.300124403 -0.569451122 0.025151321 -0.314405805 -0.643318808
## [586] -0.643318808 -1.114843481 -0.546433592 -0.561068490 -0.250130913
## [591] -1.274791012 -0.998260896 0.311018980 -0.945185289 -1.123900885
## [596] -1.473408874 3.133460703 -0.543911183 2.680477666 0.284091617
## [601] 1.450144824 -0.212109036 -0.998260896 -0.334457925 -0.909570584
## [606] 2.031157854 -1.040144529 0.485809871 -0.544846080 -1.647264560
## [611] 0.935238240 2.916288461 -1.173145232 -0.910027944 -0.910027944
## [616] 0.284091617 0.463035450 -1.114843481 1.470369876 0.935896312
## [621] -0.211363837 1.147901042 0.481650536 2.683002683 -0.544846080
## [626] -0.910027944 2.021671014 -1.219135491 0.545422418 1.151229340
## [631] 2.545932997 -0.659785160 -0.051700568 1.364480802 0.539437394
## [636] 1.560309780 1.096828046 -1.219135491 -0.396616045 1.200775725
## [641] 0.144006361 2.455790876 0.052207537 3.070194980 -0.771133922
## [646] -0.957652017 -0.971477986 1.246506355 -0.250130913 -0.335637112
## [651] 1.498753522 1.044011277 -1.039072111 0.291107091 -0.998260896
## [656] -0.998260896 0.620175493 0.545422418 3.747157252 -1.217888167
## [661] -0.367768322 1.197251911 -0.166085522 -0.422726515 -0.910027944
## [666] 3.864657046 -0.970395961 0.973147047 3.010083389 0.308258205
## [671] 0.842328477 0.099377076 0.343429704 0.396274349 -0.544846080
## [676] -0.829844780 -0.075376919 0.844489019 0.162973472 -0.547005087
## [681] -0.943532301 -0.910027944 -0.567598022 0.707254410 -0.569451122
## [686] -1.648162868 3.943964952 3.504491974 -0.643318808 -0.547005087
## [691] -0.547005087 -1.604396735 -0.599638902 1.843911705 -0.554823272
## [696] 0.162278595 -1.256273860 2.350871942 -0.998260896 -1.437005191
## [701] 2.022659279 -1.142969351 1.431359645 1.181554685 2.184754506
## [706] -0.997030607 -0.300124403 0.910057131 0.208434742 0.778317310
## [711] -0.910027944 -1.174499522 0.326986671 -0.997030607 -1.219135491
## [716] -1.174499522 0.326986671 -0.367768322 2.184754506 -0.772873201
## [721] -0.114762518 -1.286999997 -0.250130913 1.033918368 -1.286999997
## [726] -0.829844780 -0.955008401 1.147901042 -0.231752324 0.799041475
## [731] 1.284150500 -1.040766456 -0.333932094 -0.300124403 -0.498614069
## [736] -0.910027944 0.537143147 0.723286216 -0.829313594 -0.777386302
## [741] 0.640645677 -0.335637112 -0.246668487 -0.775714450 1.692262165
## [746] -0.092414467 -1.121794975 0.350391308 2.030889518 -0.114762518
## [751] -0.772873201 0.164326225 -0.829844780 0.842328477 -0.631671818
## [756] 0.547093673 -0.770119722 -0.786364638 2.964917046 -0.121170981
## [761] -1.109988151 -0.829313594 1.570850805 -0.957652017 -0.770423320
## [766] 2.484347323 -1.114843481 -0.631671818 0.136850418 -1.287647140
## [771] 0.702843327 1.693078975 0.193636965 -0.777386302 0.107850262
## [776] 0.193636965 -1.390568562 -0.567598022 -1.040766456 -0.631671818
## [781] -0.643318808 -0.663758144 -0.663758144 0.349744387 0.556686495
## [786] -1.040766456 1.245658611 -0.948319978 -1.040766456 -0.544846080
## [791] 0.468542331 -1.287647140 -0.647762138 0.232819849 -0.166085522
## [796] -0.544846080 -0.395943308 -1.244354416 -1.244354416 -0.647762138
## [801] -1.286516559 -0.367768322 2.686395466 -0.367768322 1.197904078
## [806] 0.768453698 0.326986671 0.538040465 -0.405067172 2.808836737
## [811] -1.577865122 -0.910027944 0.439549882 -1.114843481 0.050421452
## [816] -0.349465999 -0.776730264 1.406509943 -1.094296969 -1.090391692
## [821] -1.287647140 0.277149495 -0.002859257 0.418543128 0.448885064
## [826] -0.910027944 -0.815857135 -0.643318808 0.994503375 -1.287647140
## [831] -0.957652017 0.144006361 -0.475285065 2.035645922 0.026946767
## [836] -1.577865122 -1.241367598 2.184754506 0.910057131 0.619422202
## [841] -1.244354416 0.910190466 0.103105784 -1.298654879 0.799041475
## [846] 1.142014697 0.373237603 -0.829844780 0.624305330 0.723894985
## [851] -1.114843481 1.403911286 -0.547005087 0.106112077 2.032883379
## [856] -0.475285065 0.351082736 2.030663101 -0.910027944 1.246198684
## [861] -0.285973843 2.197715591 0.233822638 -1.040766456 1.089287832
## [866] 0.308258205 0.337857344 0.777382280 1.672722202 1.532688233
## [871] 0.697054402 0.993621855 1.852316743 -0.233442271 3.076187090
## [876] -0.829844780 1.363498672 -0.643318808 -0.547005087 0.340828040
## [881] -1.114283186 -0.117387696 1.245658611 -0.611724924 0.036225481
## [886] 1.045194473 -0.646839339 -0.910027944 0.831195221 -0.266839683
## [891] 1.032449050 0.880972423 0.164326225 1.102352516 2.545932997
## [896] -0.792793271 -1.114843481 0.555811511 -0.121170981 2.031891334
## [901] 0.846352273 3.892131900 2.479273881 -0.298599788 1.716708274
## [906] 0.937571176 -1.219135491 0.640645677 3.158136548 -0.776730264
## [911] -0.582105748 1.402029391 1.441913076 0.975410405 -0.335637112
## [916] 0.463035450 -0.114174159 0.035597277 1.447326318 -0.545499008
## [921] 0.463035450 4.230639144 0.995511541 -1.286999997 1.764452483
## [926] 1.450144824 3.840894415 1.032449050 4.599271737 3.464743193
## [931] 4.431894416 1.714129470 1.847350161 1.203458273 0.138357261
## [936] 1.677090005 0.558648996 0.800643290 0.911340272 0.550363162
## [941] 0.595148723 1.346753629 -0.149944552 1.026618088 1.672163025
## [946] -0.584110187 2.994120149 3.569928551 0.653331774 1.583105298
## [951] -0.771133922 0.762018675 2.986986022 3.562478924 -0.949146891
## [956] 1.110389622 2.571664588 -0.569451122 -0.424111542 3.017205543
## [961] 1.907988560 2.203032111 2.103972504 2.430532889 2.097912321
## [966] 2.478632079 0.545422418 0.545422418 1.136015254 -0.569451122
## [971] 4.349081509 4.034054095 1.846417492 2.721010476 2.721010476
## [976] 1.818622172 0.550363162 -0.948319978 -1.515771270 0.503279225
## [981] 3.980186252 -0.556511707 0.694889996 2.448857178 -0.569451122
## [986] -0.776730264 0.183117032 2.483259990 -1.109100327 0.582892313
## [991] -0.258934462 1.028996619 2.633495392 4.332510467 -0.998260896
## [996] -0.998260896 2.224237258 0.596484486 0.514354909 2.217315446
## [1001] 2.752105644 -0.792793271 -0.335637112 0.060444782 -1.411863406
## [1006] 2.515687903 1.001072320 1.799148995 0.314110444 2.430532889
## [1011] 3.987521094 0.825499604 3.987521094 0.723286216 1.034850332
## [1016] 1.355096949 2.374751851 -0.318049183 4.185728039 -1.256273860
## [1021] 3.195736761 -0.556511707 1.910116970 0.310150022 3.013467500
## [1026] -0.945185289 -0.945185289 -0.617683783 -0.829844780 -1.577865122
## [1031] 2.233161074 -0.335637112 -0.788058570 -1.088695278 -1.440010086
## [1036] -0.643318808 1.157921619 2.282093104 -0.069431426 -0.946562289
## [1041] 3.254598115 2.648961104 2.813100586 -0.349465999 -0.556511707
## [1046] 0.627832979 -0.023797443 2.480230898 -0.300124403 4.266986881
## [1051] -0.520922225 2.047609609 0.545422418 3.366520396 -1.144422932
## [1056] 1.165146124 2.881992276 -0.250130913 -0.300124403 1.902609359
## [1061] -0.149417754 0.310150022 -1.174499522 -1.174499522 5.301963075
## [1066] 1.890467147 3.750523081 -0.769456330 3.872651047 -0.544841486
## [1071] -0.569451122 4.185728039 -0.209186797 -1.113587664 3.556867738
## [1076] 1.053037110 -0.944445322 0.547861266 3.665571186 -0.166085522
## [1081] 0.974531971 -0.910027944 0.151883513 2.870785712 -0.793885771
## [1086] -1.040766456 -0.796910208 -0.631671818 -0.259374411 -1.092265901
## [1091] 0.100555935 -0.165436719 3.321742429 2.493601277 1.289382530
## [1096] -1.174499522 -0.048603333 2.222079962 -0.395943308 -1.113864626
## [1101] 3.487126647 2.789050387 -0.149944552 -1.113458789 3.156205173
## [1106] 0.137200851 -0.335637112 3.571788937 3.308357064 -0.149671627
## [1111] 0.989610455 -0.023797443 0.193636965 5.374095562 -1.439286369
## [1116] 1.465960573 4.235366448 3.450067098 -1.287647140 5.536880380
## [1121] -0.114762518 -0.945185289 -0.367098919 4.531956212 -1.114283186
## [1126] -0.367768322 4.567169526 0.536515302 2.742138932 3.480005223
## [1131] -0.568143494 5.049381066 -1.040766456 -0.050307996 0.621765129
## [1136] 0.193636965 6.595616025 5.298560555 -1.438413492 -0.793885771
## [1141] 1.247512792 -0.785667631 -0.367098919 1.851079694 -0.643318808
## [1146] 6.697377562 0.144006361 -1.040144529 -0.771133922 8.581604805
## [1151] 4.277376435 9.568644295 -1.219135491 8.484071407 -0.257811285
## [1156] 0.538040465 -0.771133922 -1.286516559 8.989650531 5.438782338
## [1161] 0.247957676 7.773560547 6.754600275 -0.795972175 0.595995702
## [1166] -0.298599788 7.991896299 -0.519092078 0.933756972 -0.771133922
## [1171] -0.643318808 -1.219135491 -0.561068490 -0.561068490 -0.300124403
## [1176] 0.099377076 12.031688336 4.404615135 10.050287020 7.549561045
## [1181] 9.082944251 -1.219135491 0.349744387 -0.956212841 1.428040385
## [1186] -0.544846080 8.492993167 -1.286999997 -1.142969351 -0.197278717
## [1191] 0.107257197 -0.777386302 11.501391598 -0.333448540 7.939710556
## [1196] 0.830348278 1.104885045 0.281274745 0.275569902 8.586496502
## [1201] -0.584110187 -0.335637112 -1.144422932 -0.643318808 10.730167094
## [1206] -1.219135491 9.977932980 0.282177769 -0.282976040 8.052503588
## [1211] 1.098108780 -1.114843481 3.166944096 8.282226177 0.540340229
## [1216] 5.270801207 -1.040766456 0.695927685 9.178050119 0.951417438
## [1221] 1.591049643 -0.165436719 1.590153199 1.673494039 7.260932283
## [1226] 7.916895617 10.461479984 0.250642036 0.538040465 2.742015282
## [1231] -0.365370234 0.538040465 9.763288710 -0.829844780 2.065763728
## [1236] 2.065763728 -0.771133922 -0.292912213 8.398717367 -0.162511560
## [1241] 0.336093291 2.590995365 -0.910027944 -1.219135491 0.842874283
## [1246] -1.646096320 -0.367768322 -1.040766456 0.549043963 -1.219135491
## [1251] 0.907436968 8.106455584 7.375923877 0.907436968 0.694570488
## [1256] 0.250642036 -0.957652017 7.200645431 0.351082736 6.726759332
## [1261] 1.148513766 1.322655036 3.629360447 -1.274791012 4.693580677
## [1266] -1.646096320 0.396274349 6.275546296 1.147901042 -0.776730264
## [1271] -0.051700568 -0.200317929 -1.039297448 1.591049643 2.020142225
## [1276] -0.771133922 2.245941787 2.024013094 2.996374434 -0.121170981
## [1281] 2.337944950 1.877848977 -1.144422932 -1.704735677 2.911752316
## [1286] 3.275713097 -1.601866498 1.799148995 -0.910027944 2.123230350
## [1291] 0.838041768 0.848648258 3.906991272 -1.257218827 -1.114843481
## [1296] -1.257218827 -0.972816722 -0.326119262 -1.768244443 -0.770881102
## [1301] -0.910027944 0.326986671 -0.848680530 -0.367768322 1.186454267
## [1306] -0.777386302 -0.909002841 -0.643318808 -1.605725571 -0.266839683
## [1311] 2.187331732 -1.768244443 0.842874283 1.766106380 0.870035097
## [1316] -0.160865871 -1.468950554 1.622345899 -2.039152590 -0.556511707
## [1321] 1.147901042 1.147901042 -0.023797443 -1.806445498 0.036858243
## [1326] -1.604396735 -0.777386302 -1.489125586 -1.123900885 0.212469146
## [1331] -1.219135491 -0.210568358 -1.840946695 -0.258934462 -1.604396735
## [1336] -0.643318808 -0.556511707 -2.039152590 -1.274791012 -1.704735677
## [1341] -2.039152590 0.548972318 -0.643318808 -1.822916862 0.547861266
## [1346] 0.194132812 -1.287647140 -0.642753961 -0.771133922 -0.771133922
## [1351] -1.577865122 -1.174499522 -0.777386302 0.025595180 -0.956212841
## [1356] 0.343429704 -0.771133922 0.835433788 -0.642995490 0.107850262
## [1361] -0.052208337 -0.300124403 -0.972085521 -0.053243719 -0.053243719
## [1366] -0.770423320 -0.556511707 -1.114843481 -0.149944552 -0.642594141
## [1371] -0.910027944 -0.211722960 -0.910027944 -0.910027944 -1.114843481
## [1376] -1.114843481 -0.149671627 -0.643318808 -1.287647140 -0.910027944
## [1381] -0.544846080 -0.555878229 -0.777386302 0.025151321 -0.335637112
## [1386] -0.300124403 -0.547005087 -0.643318808 -1.144422932 -0.335637112
## [1391] -0.366476249 -0.793885771 -0.910027944 -0.643318808 1.422874181
## [1396] -0.546433592 2.255197949 0.723286216 -0.599638902 -0.561068490
## [1401] -0.544846080 4.121218474 1.680563147 2.191610202 1.215288770
## [1406] 2.034134604 1.673494039 -0.114762518 1.402881047 1.471621802
## [1411] -0.212109036 -0.212109036 -0.642995490 -1.286999997 2.339676480
## [1416] 0.512325361 0.775808955 -0.114762518 -0.947613719 -0.047759891
## [1421] 0.803814718 -0.333448540 -0.299578124 -0.942932488 0.640645677
## [1426] 1.038441619 3.249020969 3.260335695 1.674921069 0.213358348
## [1431] 1.498753522 3.177448388 -0.113600364 -1.646096320 0.942266710
## [1436] -0.114762518 -1.217888167 4.287550586 -0.972816722 0.336093291
## [1441] -0.972816722 0.933756972 4.658112005 3.028272546 -0.166026483
## [1446] -0.114762518 -0.643318808 -0.643318808 -1.287647140 -0.776173046
## [1451] -0.544846080 1.401355965 0.538040465 -0.945185289 -1.604396735
## [1456] -0.300124403 -0.643318808 -0.164809003 -0.554050024 -1.286999997
## [1461] -0.643318808 -0.643318808 -0.643318808 -0.544846080 -0.211722960
## [1466] -0.909228921 -0.300124403 -0.643318808 -0.250130913 0.760941731
## [1471] -0.643318808 -1.287647140 -0.053243719 2.350871942 -0.910027944
## [1476] -0.910027944 -0.776730264 -0.642753961 -0.774392896 -1.331193847
## [1481] -1.331193847 -0.910027944 0.934279017 -0.828567565 1.650196211
## [1486] -0.998260896 5.603232125 1.961065222 -1.287647140 -0.149182842
## [1491] -0.367768322 -0.114762518 -0.909570584 3.010083389 -1.438672385
## [1496] -0.544846080 2.680477666 -1.287647140 2.997421414 -0.949146891
## [1501] -1.297094753 1.028996619 -0.615579566 0.485809871 -0.568143494
## [1506] -0.793885771 -0.335637112 -1.174499522 -0.250130913 1.999112700
## [1511] 2.747164783 3.274031185 -1.822916862 0.845366808 -0.910027944
## [1516] 1.091114298 0.136850418 -0.643318808 -0.556511707 -0.149944552
## [1521] 0.310150022 -0.910027944 -1.108353606 0.060444782 -0.957652017
## [1526] -0.599638902 0.440988280 -0.556511707 0.466467383 2.215551902
## [1531] -1.114843481 0.595148723 0.036225481 1.913220210 -0.643318808
## [1536] 0.036858243 -0.166085522 -0.211722960 0.136850418 -0.560296379
## [1541] 0.239193748 0.162973472 2.765379394 3.578780165 3.315878754
## [1546] 0.780486343 -0.769810740 -1.040766456 -1.123900885 -0.113040916
## [1551] -0.298599788 -1.114843481 -1.473408874 -1.473408874 0.025595180
## [1556] 8.587563201 9.017413033 10.251570130 -1.287647140 -0.114762518
## [1561] -0.582105748 0.768735861 10.979765483 1.714129470 3.504491974
## [1566] -1.219135491 -0.335637112 -0.050703932 1.283598961 -0.207312617
## [1571] 1.362054773 -0.166085522 -1.114843481 -0.829844780 -0.829844780
## [1576] -1.577865122 0.485809871 3.840220241 3.487604892 3.379235740
## [1581] 0.640645677 0.326986671 -1.769199597 -1.287647140 -0.910027944
## [1586] -0.998260896 -0.910027944 -0.075376919 2.087851280 0.035597277
## [1591] 0.765417918 -0.091510064 2.614837261 2.217453535 -1.114283186
## [1596] 0.277149495 -0.472185898 -0.633997911 -1.114843481 -1.287647140
## [1601] 1.998282298 1.656579087 -1.473408874 -1.040766456 -0.771133922
## [1606] -1.040766456 -1.577865122 -0.367768322 -1.286999997 2.866661899
## [1611] 3.062964940 -0.910027944 1.656726167 4.274302632 -0.300124403
## [1616] -0.299069982 0.992269013 0.706191803 2.721937143 2.484347323
## [1621] 8.384228395 -0.561068490 -0.555878229 1.470171932 1.393830285
## [1626] 2.631656260 -1.114283186 -0.829844780 -0.910027944 -1.257218827
## [1631] -1.257218827 -0.943563454 0.837639756 -0.972816722 9.200705393
## [1636] -0.166085522 -1.123900885 -0.547005087 -0.394748362 -0.300124403
## [1641] 0.035597277 -0.318898313 -1.114843481 -0.768559503 -0.793885771
## [1646] -1.287647140 -0.598132684 1.364480802 -0.793885771 -0.998260896
## [1651] -0.787161522 9.878128379 -0.642995490 6.483426345 -0.643318808
## [1656] 5.914030828 -0.543911183 -1.217888167 -0.776173046 -0.777386302
## [1661] 1.181159701 0.310150022 1.908931284 4.185728039 -0.335637112
## [1666] 0.627832979 1.558423949 -1.411863406 -0.956212841 -0.910027944
## [1671] 1.181159701 0.195198652 -0.770119722 -0.945105011 1.451641530
## [1676] -1.174499522 -0.998260896 -0.584110187 -1.039297448 -0.793885771
## [1681] -0.829844780 0.107257197 -1.114843481 -1.114843481 -0.910027944
## [1686] 2.345545344 1.552503792 0.538603878 -0.998260896 -1.438745728
## [1691] -0.643318808 -0.643318808 -0.349465999 -1.604396735 -1.604396735
## [1696] -0.829844780 -0.544846080 -0.998260896 -0.828567565 -1.577865122
## [1701] -1.144422932 -1.144422932 -0.544846080 -0.643318808 -0.051169860
## [1706] 0.311018980 -0.776173046 -0.972085521 -1.222476922 5.503561368
## [1711] -0.776173046 -0.569451122 0.396274349 1.214292969 -0.642995490
## [1716] 1.169424922 -1.100832075 0.043631880 4.533071015 3.001715469
## [1721] -0.643318808 -0.643318808 0.463035450 -0.367768322 -1.144422932
## [1726] -1.517964762 -0.211031534 0.035597277 -0.910027944 -1.114843481
## [1731] -1.287647140 -0.053243719 -1.040766456 0.768735861 -1.040766456
## [1736] -0.998260896 -1.440010086 -0.910027944 0.162973472 0.843527227
## [1741] 2.023741743 1.788055990 -0.998260896 -0.643318808 -0.643318808
## [1746] 0.440517649 -1.114843481 0.880972423 11.744236891 -1.840946695
## [1751] 0.704338064 5.363403128 -1.577865122 0.440988280 1.703968581
## [1756] 0.980176112 0.801597402 1.594956769 0.627767191 8.788578418
## [1761] 1.210485050 -1.244354416 1.210485050 0.539547912 -0.910027944
## [1766] -0.829844780 -0.298599788 -0.909002841 -0.774392896 0.768735861
## [1771] 3.329339413 0.880147423 -1.174499522 -0.971477986 13.097040369
## [1776] 2.335817378 -1.287647140 -0.780382428 1.054226847 -0.556511707
## [1781] -0.556511707 2.317986567 1.499711750 0.025151321 -0.568143494
## [1786] -0.397339273 -0.997030607 0.448885064 4.399326244 -0.793885771
## [1791] -1.113864626 -0.998260896 -0.777386302 0.237280077 1.165949144
## [1796] 0.547861266 -0.910027944 -0.335637112 -0.981330027 -1.100832075
## [1801] -0.556511707 -0.949146891 3.274031185 -0.259847379 0.595148723
## [1806] 1.555816913 -1.440010086 2.782643462 2.021671014 -1.331193847
## [1811] -0.561068490 -1.144422932 3.464743193 6.314818861 -0.910027944
## [1816] -1.144422932 0.336953927 -0.559672325 -1.287647140 1.672163025
## [1821] -0.770423320 0.035597277 7.070212567 -0.957652017 1.285743629
## [1826] -0.402301831 0.193636965 0.006737978 1.545433152 -0.114762518
## [1831] -0.910027944 1.198708520 1.921801753 -1.114843481 -0.957652017
## [1836] -0.561068490 -0.547005087 0.622909597 1.845134823 1.210485050
## [1841] -0.949146891 0.640645677 0.349744387 -0.053243719 -0.300124403
## [1846] 1.379421811 -0.584110187 0.193636965 -0.777386302 1.165949144
## [1851] 0.237280077 -0.023797443 -0.561068490 -0.774392896 -0.615579566
## [1856] -1.374812478 0.880147423 -1.440010086 -1.114843481 -0.769456330
## [1861] -0.561068490 -0.053243719 -1.109988151 -0.998260896 0.440192735
## [1866] 0.056417385 -0.555315485 -0.365900079 0.595148723 -1.114843481
## [1871] -0.910027944 -0.777386302 -0.567598022 -0.944445322 -0.828887905
## [1876] -0.643318808 0.448885064 0.595148723 1.471621802 1.531896517
## [1881] -0.949146891 -0.998260896 -0.053243719 -0.051199159 0.545422418
## [1886] -0.210568358 -1.286516559 -0.829844780 0.310150022 -1.287647140
## [1891] -0.162511560 1.485065233 -1.331193847 -0.114762518 1.497409031
## [1896] -0.970993906 -0.395320811 -0.777386302 -0.052722656 2.497503890
## [1901] 0.481650536 -0.545931626 -0.367768322 -0.776730264 -1.040766456
## [1906] 2.880219522 0.485809871 -0.598132684 0.306648697 -0.210568358
## [1911] 3.163910794 0.281274745 -1.576479724 2.188556978 -0.643318808
## [1916] -0.642753961
## attr(,"gstari")
## [1] FALSE
## attr(,"call")
## localG(x = parqs$Acidentes.y, listw = nb2listw(dnb, style = "B"),
## zero.policy = NULL, spChk = NULL, return_internals = FALSE)
## attr(,"class")
## [1] "localG"
Todas as análises feitas até o momento foram de escala global. No entanto, é necessário que seja feita também uma análise local do estudo. Essa análise pode ser feita pelo índice local de autocorrelaçãoo espacial (LISA). Para isso é preciso calcular o índice de Moran local.
ShapePB.mloc <- localmoran(parqs$Acidentes.y, listw=nb2listw(dnb, style="W"))
head(ShapePB.mloc)
## Ii E.Ii Var.Ii Z.Ii Pr(z != E(Ii))
## 1 0.09622536 -2.159550e-04 0.41368036 0.1499446 0.8808084
## 2 0.09622536 -1.169172e-05 0.02240107 0.6429955 0.5202270
## 3 0.41355376 -2.159550e-04 0.13774936 1.1148435 0.2649175
## 4 0.41355376 -2.159550e-04 0.13774936 1.1148435 0.2649175
## 5 0.41355376 -2.159550e-04 0.41368036 0.6433188 0.5200173
## 6 0.09622536 -2.159550e-04 0.20673211 0.2121090 0.8320220
Por meio dos valor-p do éndice de Moran local é possível construir um mapa de probabilidades.
library(classInt)
INT4 <- classIntervals(ShapePB.mloc[,5], style="fixed",
fixedBreaks=c(0,0.01, 0.05, 0.10))
CORES.4 <- c(rev(brewer.pal(3, "Reds")), brewer.pal(3, "Blues"))
COL4 <- findColours(INT4, CORES.4)
parqs$COL = COL4
parqs$p_valor = ifelse(parqs$COL == "#DE2D26", "[0,0.01)", ifelse(parqs$COL == "#EEE5E4", "[0.01,0.05)", "[0.05,0.1]"))
plot(parqs, col=COL4)
title("P-valores do I de Moran Local por Distäncia de Centróides")
TB4 <- attr(COL4, "table")
legtext <- paste(names(TB4))
legend("bottomright", fill=attr(COL4, "palette"), legend=legtext,
bty="n", cex=0.7, y.inter=0.7)
A caption
mapview(parqs, zcol = "p_valor", col.regions=c("red", "orange", "green"))
temp = parqs[parqs$p_valor != "[0.05,0.1]", ]
mapview(temp, zcol = "p_valor", col.regions=c("red", "orange"))
ShapeCG.nb1.mat <- nb2mat(dnb)
Acidentes_SD <- scale(parqs$Acidentes.y)
Acidentes_W <- ShapeCG.nb1.mat %*% Acidentes_SD
plot(Acidentes_SD, Acidentes_W,xlab="Z",ylab="WZ")
abline(v=0, h=0)
title("Diagrama de Espalhamento de Moran por Distancia de Centróides")
A caption
Q <- vector(mode = "numeric", length = nrow(ShapePB.mloc))
Q[(Acidentes_SD>0 & Acidentes_W > 0)] <- 1
Q[(Acidentes_SD<0 & Acidentes_W < 0)] <- 2
Q[(Acidentes_SD>=0 & Acidentes_W < 0)] <- 3
Q[(Acidentes_SD<0 & Acidentes_W >= 0)]<- 4
signif=0.05
parqs$Q = Q
Q[ShapePB.mloc[,5]>signif]<-5
CORES.5 <- c("blue", "green" , "red", "yellow", "gray", rgb(0.95,0.95,0.95))
#CORES.5 <- c(1:5, rgb(0.95,0.95,0.95))
parqs$cores5Q = CORES.5[Q]
plot(parqs, col=CORES.5[Q])
title("Mapa LISA por Distancia Centroides")
legend("bottomright", c("Q1(+/+)", "Q2(-/-)", "Q3(+/-)", "Q4(-/+)","NS"),
fill=CORES.5)
A caption
CORES.5[Q][1:5]
## [1] "gray" "gray" "gray" "gray" "gray"
head(CORES.5[Q])
## [1] "gray" "gray" "gray" "gray" "gray" "gray"
#save(parqs, file = "parqsFinal-975.Rds")
parqs$cores5 = ifelse(parqs$cores5Q == "blue", "A-A", ifelse(parqs$cores5Q == "green", "B-B",
ifelse(parqs$cores5Q == "red", "A-B", ifelse(parqs$cores5Q == "yellow", "B-A", "NA"))))
mapview(parqs, zcol = "cores5", col.regions=c("red", "orange", "green", "yellow", "grey"))
temp = parqs[parqs$cores5 == "A-A", ]
mapview(temp, zcol = "cores5", col.regions=c("red", "orange", "green", "yellow", "grey"))
mapview(temp, zcol = "Acidentes.x", col.regions=brewer.pal(9, "YlOrRd"))