-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy path13-Activity-Point-Pattern-Analysis-III.Rmd
More file actions
111 lines (75 loc) · 4.77 KB
/
Copy path13-Activity-Point-Pattern-Analysis-III.Rmd
File metadata and controls
111 lines (75 loc) · 4.77 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
---
title: "Activity 6: Point Pattern Analysis III"
output: html_notebook
---
# Activity 6: Point Pattern Analysis III
Remember, you can download the source file for this activity from [here](https://github.com/paezha/Spatial-Statistics-Course).
## Practice questions
Answer the following questions:
1. List and explain two limitations of quadrat analysis.
2. What is clustering? What could explain a clustering in a set of events?
3. What is regularity? What could explain it?
4. Describe the concept of nearest neighbors.
5. What is a cumulative distribution function?
## Learning objectives
In this activity, you will:
1. Explore a dataset using distance-based approaches.
2. Compare the characteristics of different types of patterns.
3. Discuss ways to evaluate how confident you are that a pattern is random.
## Suggested reading
O'Sullivan D and Unwin D (2010) Geographic Information Analysis, 2nd Edition, Chapter 5. John Wiley & Sons: New Jersey.
## Preliminaries
For this activity you will need the following:
* An R markdown notebook version of this document (the source file).
* A package called `geog4ga3`.
It is good practice to clear the working space to make sure that you do not have extraneous items there when you begin your work. The command in R to clear the workspace is `rm` (for "remove"), followed by a list of items to be removed. To clear the workspace from _all_ objects, do the following:
```{r}
rm(list = ls())
```
Note that `ls()` lists all objects currently on the workspace.
Load the libraries you will use in this activity. In addition to `tidyverse`, you will need `spatstat`, a package designed for the analysis of point patterns (you can learn about `spatstat` [here](https://cran.r-project.org/web/packages/spatstat/vignettes/getstart.pdf) and [here](http://spatstat.org/resources/spatstatJSSpaper.pdf)):
```{r message=FALSE, warning=FALSE}
library(tidyverse)
library(spatstat)
library(maptools) # Needed to convert `SpatialPolygons` into `owin` object
library(sf)
library(geog4ga3)
```
In the practice that preceded this activity, you learned about the concepts of intensity and density, about quadrats, and also how to create density maps. For this practice, you will use the data that you first encountered in Activity 4, that is, the business locations in Toronto.
Begin by reading the geospatial files, namely the city boundary of Toronto. You need the `sf` object, which will be converted into a `spatstat` window object:
```{r}
data("Toronto")
```
Convert the `sf` object to an `owin` object (via `SpatialPolygons`, hence `as(x, "Spatial")`:
```{r}
Toronto.owin <- as.owin(as(Toronto, "Spatial")) # Requires `maptools` package
```
Next the data that you will use in this activity needs to be loaded. Each dataframe is converted into a `ppp` object using the `as.ppp` function, again after extracting the coordinates of the events from the `sf` object:
```{r}
data("Fast_Food")
Fast_Food.ppp <- as.ppp(st_coordinates(Fast_Food), W = Toronto.owin)
# Add the classes of fast food to the ppp object:
marks(Fast_Food.ppp) <- Fast_Food$Class
data("Gas_Stands")
Gas_Stands.ppp <- as.ppp(st_coordinates(Gas_Stands), W = Toronto.owin)
data("Paez_Mart")
Paez_Mart.ppp <- as.ppp(st_coordinates(Paez_Mart), W = Toronto.owin)
```
If you inspect your workspace, you will see that the following `ppp` objects are there:
* `Fast_Food.ppp`
* `Gas_Stands.ppp`
* `Paez_Mart.ppp`
These are locations of fast food restaurants and gas stands in Toronto (data are from 2008). Paez Mart on the other hand is a project to cover Toronto with convenience stores. The points are the planned locations of the stores.
You can check the contents of `ppp` objects by means of `summary`:
```{r}
summary(Fast_Food.ppp)
```
Now that you have the data that you need in the right format, you are ready for the next activity.
## Activity
**NOTE**: Activities include technical "how to" tasks/questions. Usually, these ask you to organize data, create a plot, and so on in support of analysis and interpretation. These tasks are indicated by a star (*).
1. (*)Calculate the event-to-event distances to nearest neighbors using the function `nndist()`. Do this for all fast food establishments (pooled) and then for each type of establishment (i.e, "Chicken", "Hamburger", "Pizza", "Sub").
2. (*)Create Stienen diagrams using the distance vectors obtained in Step 1.
3. (*)Plot the empirical G-function for all fast food establishments (pooled) and then for each type of establishment (i.e, "Chicken", "Hamburger", "Pizza", "Sub").
4. Discuss the diagrams that you created in Question 2 with a fellow student.
5. Is there evidence of clustering/regularity?
6. How confident are you to make a decision whether the patterns are not random? What could you do to assess your confidence in making a decision whether the patterns are random? Explain.