-
Notifications
You must be signed in to change notification settings - Fork 19
/
intro-rgeoda.Rmd
84 lines (60 loc) · 1.1 KB
/
intro-rgeoda.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
---
title: "Intro to rgeoda"
author: "Angela Li"
date: "11/19/2019"
output:
pdf_document: default
html_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Load data
```{r}
library(rgeoda)
library(geodaData)
library(sf)
guerry_sf <- geodaData::guerry
```
## Plot maps
```{r}
plot(guerry_sf)
```
Explore data, looks like this a a Lambert Conformal Conic Projection.
```{r}
head(guerry_sf)
st_crs(guerry_sf)
```
```{r}
guerry <- sf_to_geoda(guerry_sf, with_table = TRUE)
class(guerry)
```
```{r}
guerry$table
guerry$n_cols
```
## Calculate queen weights
```{r}
queen_w <- queen_weights(guerry)
```
To save this....
```{r}
class(queen_w)
queen_w$SaveToFile("queen_weights.gal",
"guerry",
"CODE_DE",
guerry$GetIntegerCol("CODE_DE"))
```
## Local Moran
```{r}
lisa <- local_moran(queen_w, guerry$GetIntegerCol("crm_prp"))
class(lisa)
```
```{r}
lisa$GetLISAValues()
lisa_colors <- lisa$GetColors()
lisa_labels <- lisa$GetLabels()
lisa_clusters <- lisa$GetClusterIndicators()
lisa_colors
lisa_clusters
```