#spatiallibrary(lwgeom)library(raster)library(sf)#data wranglinglibrary(dplyr)#INLAlibrary(INLA)#data vizlibrary(ggplot2)library(viridis)m <-getData(name ="GADM", country ="Spain", level =0) # warning indicating that {geodata} should used
## Warning in getData(name = "GADM", country = "Spain", level = 0): getData will be removed in a future version of raster
## . Please use the geodata package instead
plot(m)
10.1.2 Filter to only get main territory
m <- m %>%st_as_sf() %>%st_cast("POLYGON") %>%mutate(area =st_area(.)) %>%arrange(desc(area)) %>%slice(1)
## Warning in st_cast.sf(., "POLYGON"): repeating attributes for all
## sub-geometries for which they may not be constant
m <-st_transform(m, 25830) ggplot(m) +geom_sf() +theme_bw() +coord_sf(datum =st_crs(m)) # did not know that !