-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreating shape file monthly.Rmd
76 lines (54 loc) · 1.08 KB
/
creating shape file monthly.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
---
title: "Creating shape file cumulative monthly covid case Indonesia"
output: html_notebook
---
#libraries
```{r}
library(tidyverse) # Modern data science workflow
library(sf) # Simple features for R
library(tmap) # Thematic Maps
```
#import non spatial data
```{r}
library(readr)
covid <- read_delim("D:/Mygithub/data-indonesia-covid19/monthlycases.csv",
";", escape_double = FALSE, trim_ws = TRUE)
View(covid)
```
#import shape file
```{r}
map <- read_sf("province border.shp")
```
```{r}
glimpse(map)
```
# Merge non spatial and spatial data
```{r}
covid_map <- inner_join(
covid,
map,
by = "ID"
)
```
## Keep data as sf object
- Keep the data as sf class, so we will not lose the coodinate system
```{r}
covid_map <- st_as_sf(covid_map)
```
```{r}
glimpse(covid_map)
```
# Plot Thematic Maps
## Quick Map
- A quick map of the rate in month 3
```{r}
qtm(covid_map, fill = "ratemo3")
```
- A quick map of the case in month 3
```{r}
qtm(covid_map, fill = "casemo3")
```
#save the shape file
```{r}
st_write(covid_map, "covid_map_monthlyrate.shp")
```