path <- "C://Users//np83zg//OneDrive - Aalborg Universitet//Skrivebord//kommunedata//data"
setwd(path)
library(data.table)
library(sf)
## Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
library(ttwa)
## Warning: package 'ttwa' was built under R version 4.0.3
library(tmap)
dt <- read.table("hp_index.txt",header=TRUE)
dt <- setDT(dt)
shp <- read_sf("mun_shape.shp")
shp <- shp[order(shp$kode),]
shp$zone <- as.numeric(dt[year==1996,]$effect)
breaks <- c(8, 8.5, 9, 9.5,10,10.5,11)
tmap_mode("plot")
## tmap mode set to plotting
## tmap mode set to plotting
tm_shape(shp) + tm_polygons("zone",palette="viridis",auto.palette.mapping = FALSE,n=6,breaks=breaks) +
tm_shape(shp) + tm_borders("white", lwd = 1.2)
## Warning: The argument auto.palette.mapping is deprecated. Please use midpoint
## for numeric data and stretch.palette for categorical data to control the palette
## mapping.

shp$zone <- as.numeric(dt[year==2001,]$effect)
tmap_mode("plot")
## tmap mode set to plotting
## tmap mode set to plotting
tm_shape(shp) + tm_polygons("zone",palette="viridis",auto.palette.mapping = FALSE,n=6,breaks=breaks) +
tm_shape(shp) + tm_borders("white", lwd = 1.2)
## Warning: The argument auto.palette.mapping is deprecated. Please use midpoint
## for numeric data and stretch.palette for categorical data to control the palette
## mapping.

shp$zone <- as.numeric(dt[year==2006,]$effect)
tmap_mode("plot")
## tmap mode set to plotting
## tmap mode set to plotting
tm_shape(shp) + tm_polygons("zone",palette="viridis",auto.palette.mapping = FALSE,n=6,breaks=breaks) +
tm_shape(shp) + tm_borders("white", lwd = 1.2)
## Warning: The argument auto.palette.mapping is deprecated. Please use midpoint
## for numeric data and stretch.palette for categorical data to control the palette
## mapping.

shp$zone <- as.numeric(dt[year==2011,]$effect)
tmap_mode("plot")
## tmap mode set to plotting
## tmap mode set to plotting
tm_shape(shp) + tm_polygons("zone",palette="viridis",auto.palette.mapping = FALSE,n=6,breaks=breaks) +
tm_shape(shp) + tm_borders("white", lwd = 1.2)
## Warning: The argument auto.palette.mapping is deprecated. Please use midpoint
## for numeric data and stretch.palette for categorical data to control the palette
## mapping.

shp$zone <- as.numeric(dt[year==2017,]$effect)
tmap_mode("plot")
## tmap mode set to plotting
## tmap mode set to plotting
tm_shape(shp) + tm_polygons("zone",palette="viridis",auto.palette.mapping = FALSE,n=6,breaks=breaks) +
tm_shape(shp) + tm_borders("white", lwd = 1.2)
## Warning: The argument auto.palette.mapping is deprecated. Please use midpoint
## for numeric data and stretch.palette for categorical data to control the palette
## mapping.
## Warning: Values have found that are higher than the highest break
