-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path06-prac-01-BluePlaques.Rmd
85 lines (68 loc) · 1.69 KB
/
06-prac-01-BluePlaques.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
---
title: "BluePlaques"
author: "yiyan Sun"
date: "2023-11-17"
output: html_document
---
# packages
```{r}
library(spatstat) #spatstat is a package for analyzing spatial point pattern data
library(here)
library(sp)
library(tmap)
library(sf)
library(tidyverse)
library(stringr)
library(geojson)
library(geojsonio)
library(tmaptools)
library(rgeos)
library(maptools)
```
# read data
```{r}
LondonBorough <- st_read("wk1/london_borough/data/statistical-gis-boundaries-london/ESRI/London_Borough_Excluding_MHW.shp")%>%
st_transform(., crs = 27700)
# get the location of all Blue Plaques in the City
BluePlaques <- st_read("https://s3.eu-west-2.amazonaws.com/openplaques/open-plaques-london-2018-04-08.geojson") %>%
st_transform(., crs = 27700)
BoroughMap <- LondonBorough %>%
dplyr::filter(str_detect(GSS_CODE, "E09")) %>%
st_transform(., crs = 27700)
```
# extract the borough
```{r}
# select by attribute
Harrow <- BoroughMap %>%
dplyr::filter(., NAME=="Harrow") %>%
st_transform(., crs = 27700)
# check the shape of harrow borough
tm_shape(Harrow)+
tm_polygons(col=NA, alpha = 0.5)
```
clip the data to single borough
```{r}
BluePlaquesSub <- BluePlaques[Harrow,]
tmap_mode("plot")
tm_shape(Harrow)+
tm_polygons(col=NA, alpha = 0.5)+
tm_shape(BluePlaquesSub)+
tm_dots(col="red", size = 0.1)
```
set a window at the borough boundary
```{r}
window <- as.owin(Harrow)
plot(window)
```
spatstat <- point pattern(ppp) object
```{r}
# create a sp object
BluePlaquesSub <- as(BluePlaquesSub, "Spatial")
# create a ppp object
BluePlaquesSub.ppp <- ppp(x=BluePlaquesSub@coords[,1],
y=BluePlaquesSub@coords[,2],
window=window)
```
```{r}
Bl
```