-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstationdist.Rmd
More file actions
87 lines (69 loc) · 2.38 KB
/
Copy pathstationdist.Rmd
File metadata and controls
87 lines (69 loc) · 2.38 KB
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
---
title: "Distance between Seoul Stations"
output: github_document
always_allow_html: yes
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(sf)
library(knitr)
library(kableExtra)
```
```{r variables, include=F, echo=FALSE, message=FALSE, warning=FALSE, paged.print=TRUE}
library(sf)
library(shiny)
shp <- st_read("~/Dropbox (Cambridge University)/2019_Cambridge/[Programming]/R/Spatial-Interpolation/seoul/Seoul_City.shp")
st <- st_read("~/Dropbox (Cambridge University)/2019_Cambridge/[Programming]/R/Spatial-Interpolation/seoul/stations_10km.shp")
rd <- st_read("~/Dropbox (Cambridge University)/2019_Cambridge/[Programming]/R/Spatial-Interpolation/seoul/road_10km.shp")
back <- st %>% filter(F.R == "Fixed")
road <- st %>% filter(F.R == "Road")
```
## Stations
```{r table, echo=FALSE, message=FALSE, warning=FALSE, paged.print=TRUE}
stations <- st %>%
select(-c(X,Y,Station,Road_Dist)) %>%
st_set_geometry(NULL) %>%
arrange(F.R)
kable(stations, caption = "Group Rows") %>%
kable_styling("striped", full_width = F) %>%
pack_rows("Background Stations", 1, 57) %>%
pack_rows("Roadside Stations", 58, 76)
```
## Maps
```{r map1, message=FALSE, echo=F, warning=F}
#plot(st_geometry(rd), col = 'grey',key.pos=NULL, reset = F,axes = TRUE, main = "")
#plot(st_geometry(shp), add = T)
#plot(st["F.R"], pch = 19 , add = T)
#mapview::mapview(st["F.R"])
ggplot() +
geom_sf(data = shp, color = 'black', size = .7, alpha = .5) +
geom_point(data = st, aes(x = X, y = Y, colour = F.R)) +
#geom_sf(data = rd, colour = "grey") +
theme_bw() +
theme(axis.title.x=element_blank(),
#axis.text.x=element_blank(),
axis.ticks.x=element_blank(),
#axis.text.y=element_blank(),
axis.title.y=element_blank(),
strip.text.x = element_text(size = 20),
legend.title=element_text(size=15),
legend.text=element_text(size=15),
legend.position="bottom"
)
```
## Distance
```{r dist, warning=F}
result.back <- st_distance(back, back, by_element = F)
result.road <- st_distance(road, road, by_element = F)
colnames(result.back) <- back$Name
colnames(result.road) <- road$Name
result.back %>% View()
mean(result.back)
median(result.back)
min(result.back > 0)
mean(result.back[11,])/1000
median(result.back[11,])/1000
head(sort(result.back[11,]), 3)
max(result.back[11,])/1000
```