This repository has been archived by the owner on Dec 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
README.Rmd
89 lines (70 loc) · 4.01 KB
/
README.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
83
84
85
86
87
88
89
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# stlcsb <img src="man/figures/logo.png" align="right" />
[![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing)
[![Travis-CI Build Status](https://travis-ci.org/slu-openGIS/stlcsb.svg?branch=master)](https://travis-ci.org/slu-openGIS/stlcsb)
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/slu-openGIS/stlcsb?branch=master&svg=true)](https://ci.appveyor.com/project/chris-prener/stlcsb)
[![Coverage status](https://codecov.io/gh/slu-openGIS/stlcsb/branch/master/graph/badge.svg)](https://codecov.io/github/slu-openGIS/stlcsb?branch=master)
[![DOI](https://zenodo.org/badge/120821460.svg)](https://zenodo.org/badge/latestdoi/120821460)
[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/stlcsb)](https://cran.r-project.org/package=stlcsb)
The goal of `stlcsb` is to provide access to data from the City of St. Louis [Citizens’ Service Bureau](https://www.stlouis-mo.gov/government/departments/public-safety/neighborhood-stabilization-office/citizens-service-bureau/index.cfm) (CSB), the [3-1-1 service](https://en.wikipedia.org/wiki/3-1-1) for the City of Saint Louis. Residents can contact the number with non-emergency service requests, and the CSB will dispatch these requests to the appropriate City agency. `stlcsb` also includes functions for cleaning and manipulating these data.
## Installation
### Installing Dependencies
You should check the [`sf` package website](https://r-spatial.github.io/sf/) and the [`stlcsb` package website](https://slu-openGIS.github.io/stlcsb/) for the latest details on installing dependencies for that package. Instructions vary significantly by operating system. For best results, have `sf` installed before you install `stlcsb`. Other dependencies, like `dplyr`, will be installed automatically with `stlcsb` if they are not already present.
### Installing stlcsb
The easiest way to get `stlcsb` is to install it from CRAN:
``` r
install.packages("stlcsb")
```
The development version of `stlcsb` can be accessed from GitHub with `remotes`:
```r
# install.packages("remotes")
remotes::install_github("slu-openGIS/stlcsb")
```
## Example Usage
`stlcsb` is used for simplified acquisition and processing of St. Louis CSB Data. In the following example, data is downloaded from the City of St. Louis, filtered to identify only calls related to waste disposal, and then projected to an sf object for mapping.
```r
> library(stlcsb)
> library(dplyr)
>
> csb <- csb_get_data(year = 2017)
trying URL 'https://www.stlouis-mo.gov/data/upload/data-files/csb.zip'
Content type 'application/x-zip-compressed' length 60999726 bytes (58.2 MB)
==================================================
downloaded 58.2 MB
>
> csb_filter(csb, var = problemcode, category = cat_waste) %>%
+ csb_missingXY(varX = srx, varY = sry, newVar = "missing") %>%
+ filter(missing == FALSE) %>%
+ csb_projectXY(varX = srx, varY = sry) -> waste_2017
```
Notice that variable names can be either quoted or unquoted, since `stlcsb` makes full use of non-standard evaluation.
Once the data are projected, they can be explored with packages like `mapview`:
```r
> library(mapview)
> mapview(waste_2017)
```
```{r exampleMap1, echo=FALSE, out.width = '60%'}
knitr::include_graphics("man/figures/waste_mapview.png")
```
These data can also be mapped using `ggplot2` once they have been projected:
```r
> library(ggplot2)
> ggplot() +
+ geom_sf(data = waste_2017, color = "red", fill = NA, size = .5)
```
```{r exampleMap2, echo=FALSE, out.width = '60%'}
knitr::include_graphics("man/figures/waste_example.png")
```
## Contributor Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](.github/CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.