Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/program--/fipio
An R :package: for lightweight FIPS code information retrieval
https://github.com/program--/fipio
information-retrieval r spatial us-data
Last synced: 24 days ago
JSON representation
An R :package: for lightweight FIPS code information retrieval
- Host: GitHub
- URL: https://github.com/program--/fipio
- Owner: program--
- License: other
- Created: 2021-10-10T04:53:00.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-25T01:41:56.000Z (7 months ago)
- Last Synced: 2024-12-03T16:12:02.293Z (about 1 month ago)
- Topics: information-retrieval, r, spatial, us-data
- Language: R
- Homepage: https://fipio.justinsingh.me
- Size: 16.9 MB
- Stars: 14
- Watchers: 1
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
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%"
)
```[![CRAN status](https://www.r-pkg.org/badges/version/fipio)](https://CRAN.R-project.org/package=fipio)
[![CRAN downloads](https://cranlogs.r-pkg.org/badges/fipio)](https://CRAN.R-project.org/package=fipio)
[![codecov](https://codecov.io/gh/program--/fipio/graph/badge.svg?token=1ODDHARQM1)](https://app.codecov.io/gh/program--/fipio)
[![R-CMD-check](https://github.com/program--/fipio/workflows/R-CMD-check/badge.svg)](https://github.com/program--/fipio/actions)
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/license/mit/)`fipio` is a **lightweight** package that makes it easy to get information about a US FIPS code.
## Installation
You can install the released version of `fipio` from [CRAN](https://cran.r-project.org/package=fipio) with:
``` r
install.packages("fipio")
```or the development version with `pak` or `remotes`:
``` r
# Using `pak`
pak::pkg_install("program--/fipio")# Using `remotes`
remotes::install_github("program--/fipio")
```## Usage
`fipio` makes it easy to get information about a US FIPS code.
Let's answer a few questions that might come up if you have a FIPS code:```{r}
fip <- "37129"# What state is `37129` in?
fipio::fips_state(fip)# Alternatively, you can use the state FIPS code by itself
fipio::fips_state("37")# What about the state abbreviation?
fipio::fips_abbr(fip)# What county is `37129`?
fipio::fips_county(fip)# It'd be nice to have this all in a data.frame...
fipio::fips_metadata(fip)# And the metadata for the state by itself...
fipio::fips_metadata("37")
```### With `sf`
`fipio` also includes functions that support geometry for FIPS codes. This requires
`sfheaders` at the very least to get an `sf`-compatible geometry object back.```{r, include = FALSE}
library(sf, quietly = TRUE)
``````{r}
# I'm doing spatial work, what's the geometry of `37129`?
fipio::fips_geometry(fip)# What if I need it with my other metadata?
fipio::fips_metadata(fip, geometry = TRUE)
```### Vectorized
`fipio` functions are inherently vectorized, so you can use them with vectors of FIPS codes easily:
```{r}
fips <- c("37129", "44001", "48115")fipio::fips_state(fips)
fipio::fips_abbr(fips)
fipio::fips_county(fips)
fipio::fips_metadata(fips)
fipio::fips_geometry(fips)
```### Reverse Geolocate Coordinates to FIPS
`fipio` contains the ability to locate the FIPS code(s) for a set of coordinates (in `WGS84`/`EPSG:4326`):
```{r}
# With a single set of coordinates
fipio::coords_to_fips(x = -119.8696, y = 34.4184)# Vectorized
fipio::coords_to_fips(
x = c(-81.4980534549709, -81.1249425046948),
y = c(36.4314781444978, 36.4911893240597)
)# With a `data.frame` or `matrix`
fipio::coords_to_fips(
x = data.frame(
X = c(-81.4980534549709, -81.1249425046948),
Y = c(36.4314781444978, 36.4911893240597)
),
coords = c("X", "Y")
)# With an `sfg` object
fipio::coords_to_fips(
x = sf::st_point(c(-81.4980534549709,
36.4314781444978)),
dim = "XY"
)# With an `sf` object
fipio::coords_to_fips(
x = sf::st_as_sf(
data.frame(X = c(-81.4980534549709, -81.1249425046948),
Y = c(36.4314781444978, 36.4911893240597)),
coords = c("X", "Y"),
crs = 4326
)
)
```