Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/spatlyu/tidyrgeoda

A tidy interface for rgeoda
https://github.com/spatlyu/tidyrgeoda

geocomputation geoinformatics giscience r spatial-analysis spatial-statistics

Last synced: about 1 month ago
JSON representation

A tidy interface for rgeoda

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "##",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# tidyrgeoda

![CRAN](https://www.r-pkg.org/badges/version/tidyrgeoda)
![r-universe](https://spatlyu.r-universe.dev/badges/tidyrgeoda)

The goal of **tidyrgeoda** is to provide an interface for **rgeoda** to integrate with **sf** objects and the **tidyverse**.

## Installation

You can install the development version of **tidyrgeoda** from [github](https://github.com/SpatLyu/tidyrgeoda):

``` r
# install.packages("devtools")
devtools::install_github("SpatLyu/tidyrgeoda",
build_vignettes = T,
dep = T)
```

or install **tidyrgeoda** from [r-universe](https://spatlyu.r-universe.dev/tidyrgeoda):

```r
install.packages('tidyrgeoda',
repos = c("https://spatlyu.r-universe.dev",
"https://cran.rstudio.com/"),
dep = TRUE)
```

## Example

This is a basic example which shows you how to use `tidyrgeoda` to create a `spatial weight matrix` and calculate the `local_moran`:

```{r example}
library(sf)
library(tidyverse)
library(tidyrgeoda)

guerry = read_sf(system.file("extdata","Guerry.shp",package = "rgeoda"))
guerry %>%
mutate(lisa = st_local_moran(.,'Crm_prs',
wt = st_weights(.,'contiguity',queen = T))) %>%
select(lisa) -> g_lisa
g_lisa

ggplot(data = g_lisa) +
geom_sf(aes(fill = lisa),lwd = .1,color = 'grey') +
scale_fill_lisa()
```