library(bmstdr) m <- getData(name = "GADM", country = "Spain", level = 0) %>% st_as_sf() %>% st_cast("POLYGON") %>% mutate(area = st_area(.)) %>% arrange(desc(area)) %>% slice(1) %>% st_transform(25830) d <- read.csv("./dataPM25.csv") %>% dplyr::select(year='ReportingYear',id='StationLocalId', long='SamplingPoint_Longitude',lat='SamplingPoint_Latitude',value='AQValue') %>% st_as_sf(coords=c('long','lat')) %>% st_set_crs(4326) %>% st_transform(25830) %>% filter(row_number() %in% st_intersects(m,.)[[1]]) %>% group_by(id) %>% filter(n()==3) %>% ungroup() %>% mutate(yr = year - min(year) + 1, s.index = as.integer(as.factor(id))) %>% arrange(s.index, yr) %>% mutate(Longitude = st_coordinates(.)[,1], Latitude = st_coordinates(.)[,2]) N <- 45 burn.in <- 5 n.report <