-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
135 lines (92 loc) · 3.57 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
---
output:
md_document:
variant: markdown_github
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
Swedish historical administrative maps
======================================
<!-- Generated by the R Markdown file README.Rmd -->
A R data package of Swedish historical administrative boundaries for parishes and counties 1600-1990. Municipal, Pastorship, Parish, Bailiwick, Contract, Magistrates court, Hundred, District court, County, Diocese and Court.
Based upon historical GIS data from the Swedish National Archive. Data on parishes and counties has
been verified, while the other types of units have not. Thus, be aware of possible inconsistencies and
faults.
### Source
"Historiska GIS-kartor (information om territoriella indelningar i Sverige från 1500-talets slut till 1900-talets slut)" historical GIS data from the Swedish National Archive released under Creative Commons CCZero.
The map projection is SWEREF99 EPSG:3006
## County map
```{r county_ex}
library(histmaps)
library(sf)
library(tidyverse)
map <- get_boundaries(1800, "county")
plot(st_geometry(map))
```
## Parish map
Meta data for parishes and counties are collected in a separate file.
```{r}
data("geom_meta")
geom_meta %>%
filter(type_id == "parish") %>%
head() %>%
knitr::kable()
```
Meta data wich can be used to easly subset data, for example by county.
```{r parish_ex}
p_map <- get_boundaries("1866", "parish")
st_map <- p_map %>% left_join(geom_meta, by = c("geom_id"))
st_map %>% filter(county == 25) %>%
ggplot() +
geom_sf(fill = "lightgrey", color = "black") +
theme_minimal()
```
## Period map
As parishes changes boundaries over the course of history a given map a certain year is not representative of the boundaries another year. To create a map for a period the parishes need to be aggregated to the lowest common denominator for that period. You can do this by supplying a date range to `get_boundaries`.
```{r period_dat}
period_map <- get_boundaries(c(1900, 1920), type = "parish")
```
The function returns a list where the first object is the map data and the second is a lookup-table for aggregating your data to the new artificial parish boundaries.
```{r period_plot}
plot(st_geometry(period_map$map))
```
```{r period_lookup}
knitr::kable(head(period_map$lookup))
```
## Map with boundaries
```{r}
data("geom_borders")
st_map_borders <- geom_borders %>%
filter(start <= 1866, end >= 1866) %>%
left_join(geom_meta, by = c("geom_id"))
ggplot() +
geom_sf(data = st_map %>% filter(county == 22), color = NA) +
geom_sf(data = st_map_borders %>% filter(county == 22)) +
theme_minimal()
```
## Adding background map
```{r}
data("eu_geom")
data("eu_border")
eu_1900 <- eu_geom %>% filter(year == 1900) %>% st_transform(st_crs(map))
eu_border_1900 <- eu_border %>% filter(year == 1900)%>% st_transform(st_crs(map))
county_map <- geom_borders %>% filter(start <= 1900, end >= 1900, type_id == "county")
lims <- st_bbox(map)
ggplot() +
geom_sf(data = eu_1900, color = NA) +
geom_sf(data =county_map, color = "gray60", size = .3) +
geom_sf(data = eu_border_1900, color = "gray60") +
coord_sf(xlim = lims[c(1,3)], ylim = lims[c(2,4)]) +
theme_void() +
theme(panel.background = element_rect(fill = "#9bbff4", color =NA))
```
```{r}
library(leaflet)
library(leafletwrapper)
county_map <- get_boundaries(1900, "county")
county_map <- county_map %>%
left_join(geom_meta, by = "geom_id")
data("hist_town")
leaf_init() %>%
leaf_polygon(county_map, interactive = T,lbl = "name.x") %>%
leaf_marker(hist_town, interactive = T,lbl = "town")
```