i'm facing the following errorand i don't know how to fix it.... and , the desired map is drown , but i connot specify the dangerous points on the map ...
library(rgdal) library(spdep) #shapefile address TWN <- readOGR(dsn="c:/Users/Uaer/Desktop/New folder (2)/irn_adm_unhcr_20190514_shp (2)",
-
layer="irn_admbnda_adm1_unhcr_20190514")
OGR data source with driver: ESRI Shapefile Source: "C:\Users\Uaer\Desktop\New folder (2)\irn_adm_unhcr_20190514_shp (2)", layer: "irn_admbnda_adm1_unhcr_20190514" with 31 features It has 16 fields
TWN_nbq<-poly2nb(TWN) #QUEEN=TRUE summary(TWN_nbq) Neighbour list object: Number of regions: 31 Number of nonzero links: 148 Percentage nonzero weights: 15.40062 Average number of links: 4.774194 Link number distribution:
3 4 5 6 7 8 9 8 9 4 5 3 1 1 8 least connected regions: 1 4 7 10 20 23 25 28 with 3 links 1 most connected region: 11 with 9 links
TWN_nbq2<-poly2nb(TWN, queen = FALSE) nb_q<-poly2nb(TWN) unclass(poly2nb(TWN, queen = FALSE)) [[1]] [1] 19 20 22 28
[[2]] [1] 5 7 31
[[3]] [1] 6 10 15 16
[[4]] [1] 12 15 16 18
[[5]] [1] 2 29 31
[[6]] [1] 3 10 12 13 16 30
[[7]] [1] 2 20 22 31
[[8]] [1] 20 21 25
[[9]] [1] 14 17 18 19 22 31
[[10]] [1] 3 6 13 26
[[11]] [1] 14 15 18
[[12]] [1] 4 6 16 18 19 23 25 27 30
[[13]] [1] 6 10 26 27 30
[[14]] [1] 9 11 17 18
[[15]] [1] 3 4 11 16 18
[[16]] [1] 3 4 6 12 15
[[17]] [1] 9 14 29 31
[[18]] [1] 4 9 11 12 14 15 19
[[19]] [1] 1 9 12 18 22 23 28
[[20]] [1] 1 7 8 22 25 28
[[21]] [1] 8 24 25
[[22]] [1] 1 7 9 19 20 31
[[23]] [1] 12 19 25 28
[[24]] [1] 21 25 27
[[25]] [1] 8 12 20 21 23 24 27 28
[[26]] [1] 10 13 27
[[27]] [1] 12 13 24 25 26 30
[[28]] [1] 1 19 20 23 25
[[29]] [1] 5 17 31
[[30]] [1] 6 12 13 27
[[31]] [1] 2 5 7 9 17 22 29
attr(,"region.id") [1] "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "10" "11" "12" "13" "14" "15" "16" "17" "18" "19" "20" "21" "22" [24] "23" "24" "25" "26" "27" "28" "29" "30" attr(,"call") poly2nb(pl = TWN, queen = FALSE) attr(,"type") [1] "rook" attr(,"sym") [1] TRUE
set Error: object 'set' not found library(broom) library(dplyr) NHSBoards_tidy <- tidy(TWN) Regions defined for each Polygons ggplot(NHSBoards_tidy, aes(x = long, y = lat, group = group)) +
- geom_polygon(color = "black", size = 0.1, fill = "lightgrey") +
- coord_equal() +
- theme_minimal()
TWN$id <- row.names(TWN) NHSBoards_tidy <- left_join(NHSBoards_tidy, TWN@data) Joining, by = "id" data <- NHSBoards_tidy %>%
- group_by(group)
map <- ggplot(NHSBoards_tidy, aes(x = long, y = lat, group = group, fill =id)) +
- geom_polygon(color = "black", size = 0.1) +
- coord_equal() +
- theme_void() +
- labs(title = "location id") +
- theme(plot.title = element_text(margin = margin(t = 40, b = -40)))
map +
- geom_text(data =data, mapping = aes(label =val
- , group = NA)
-
, cex = 4, col = "white")
Error in FUN(X[[i]], ...) : object 'val' not found