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

https://github.com/ivelasq/leaidr

An R Package for U.S. School District Shapefiles
https://github.com/ivelasq/leaidr

ggplot2 k12 k12education leaflet r rstats school-districts shapefile

Last synced: 4 months ago
JSON representation

An R Package for U.S. School District Shapefiles

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%"
)
```

# leaidr

The goal of leaidr is to provide an easy way to map U.S. school districts in R.

## Installation

You can install the development version of this package from [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("ivelasq/leaidr")
```

## About

School districts in the U.S. have associated local education agency identification numbers (LEAID) used in the [National Center for Education Statistics (NCES)](https://nces.ed.gov/) Common Core of Data. These are very useful because if you have other datasets with NCES ID’s, then you can (sometimes easily) join them.

The original shapefiles can be found on the [NCES](https://nces.ed.gov/programs/edge/Geographic/DistrictBoundaries) site. These files are from 2019. All the state-level shapefiles are saved [here](https://github.com/datalorax/us-district-shapefiles/tree/master/individ-districts).

## Get the U.S. Shapefile

Load the shapefile for the entire U.S. using `lea_get()` and the state abbreviation. Loading may take a while. You will have to load the shapefile anytime you're in a new directory/project.

If you use `lea_get()` (i.e., with `state = NULL`), you get all the district shapefiles for the whole U.S. via ROpenSci's {piggyback}.

**You must have a GITHUB_PAT before you can run `lea_get()`.** You can set a token in your [developer settings](https://github.com/settings/tokens) and save it in your R Environment. More info can be found in [Happy git with R](https://happygitwithr.com/github-pat.html).

## Use the Data

Once you have the shapefile, you can plot using packages like {leaflet} and {ggplot2}.

### {ggplot2} Example

```{r, message = FALSE, dpi = 300}
library(leaidr)

tn <- lea_get("tn")

tn %>%
sf::st_as_sf() %>%
ggplot2::ggplot() +
ggplot2::geom_sf()
```

### Mapbox example

## Acknowlegements

Many thanks to [datalorax](https://github.com/datalorax) for the incredible improvements to this package.