-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake-geojson.Rmd
56 lines (40 loc) · 1.18 KB
/
make-geojson.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
---
title: "Make GeoJSON"
output: html_notebook
---
# Overhead
```{r overhead, include = FALSE}
packages_vector <- c("tidyverse",
"sf")
need_to_install <- packages_vector[!(packages_vector %in% installed.packages()[,"Package"])]
if (length(need_to_install)) install.packages(need_to_install)
for (package in packages_vector){
library(package, character.only = TRUE)
}
```
# Remote I/O
```{r remote-io}
data_dir <- "./data/"
input_file_name <- paste0(data_dir, "sites_and_sights_v00.csv")
output_file_name <- paste0(data_dir, "sites_and_sights_v00.geojson")
```
# Parameters
```{r parameters}
LAT_LNG_EPSG <- 4326
```
# Data Reads
```{r data-reads}
input_df <- read_csv(input_file_name, col_types = cols(.default = col_character(),
X = col_double(),
Y = col_double())) %>%
mutate(category = replace_na(category, "Miscellany")) %>%
arrange(category, description)
```
# Reductions
```{r reductions}
output_sf <- st_as_sf(input_df, coords = c("Y", "X"), crs = LAT_LNG_EPSG)
```
# Write
```{r write}
st_write(output_sf, output_file_name, delete_dsn = TRUE)
```