library(sf)
library(rgdal)
library(raster)
library(leaflet.extras)
library(dplyr)
fls<-dir(path="/home/rstudio/markus/shapefiles", pattern="*shp$")
fls<-sprintf("/home/rstudio/markus/shapefiles/%s",fls)
f1<-sf:::read_sf(fls[1])
library(mapview)
f<-function(x){
out<-read_sf(x)
out<-out[,c("MALE","geometry")]
out$filename<-x
out
}
territories<-lapply(fls,f)
d<-do.call("rbind",territories)
d$year<-gsub("[^0-9]","",d$filename)
d$year<-as.numeric(d$year)
As the number of years would lead to a confusing map if I plotted all together I’ll separate them into blocks.
Go full screen and select years to view.
d %>% filter(year<2010) %>%
mapview(zcol="year",burst=TRUE) ->m
m@map %>% addFullscreenControl()
Go full screen and select years to view.
d %>% filter(year>2009) %>%
mapview(zcol="year",burst=TRUE) ->m
m@map %>% addFullscreenControl()