Title: | Access the openFEMA API |
---|---|
Description: | `rfema` allows users to access The Federal Emergency Management Agency's (FEMA) publicly available data through their API. The package provides a set of functions to easily navigate and access data from the National Flood Insurance Program along with FEMA's various disaster aid programs, including the Hazard Mitigation Grant Program, the Public Assistance Grant Program, and the Individual Assistance Grant Program. |
Authors: | Dylan Turner [aut, cre] , François Michonneau [rev, ctb] (reviewed the package for rOpenSci and patched several bugs in the prelease code, see https://github.com/ropensci/software-review/issues/484.), Marcus Beck [rev, ctb] (reviewed the package for rOpenSci, see https://github.com/ropensci/software-review/issues/484.) |
Maintainer: | Dylan Turner <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.0 |
Built: | 2024-12-05 05:43:34 UTC |
Source: | https://github.com/ropensci/rfema |
For large data requests, it can sometimes be more practical (and quicker) to download and work with the entire data set. This function provides an easy way to download any of FEMA's data sets in its entirety and save it locally as a csv file.
bulk_dl(data_set, output_dir = NULL, file_name = NULL, size_warning = TRUE)
bulk_dl(data_set, output_dir = NULL, file_name = NULL, size_warning = TRUE)
data_set |
A character string indicating the name of the data set to download |
output_dir |
An optional character string indicating the directory (defaults to working directory) |
file_name |
An optional character string indicating the file name (defaults to data set name with time stamp) |
size_warning |
A logical indicating whether to issue a warning before proceeding with downloading a large file (default is TRUE) |
Returns a downloaded csv file of the data set to the specified output directory.
## Not run: bulk_dl("femaregions") # download the file ## End(Not run) ## Not run: file.remove("FemaRegions.csv") # clean up directory after file downloads ## End(Not run)
## Not run: bulk_dl("femaregions") # download the file ## End(Not run) ## Not run: file.remove("FemaRegions.csv") # clean up directory after file downloads ## End(Not run)
Get data fields and descriptions for a given FEMA data set
fema_data_fields(data_set)
fema_data_fields(data_set)
data_set |
a character string indicating the data set of interest |
Returns a tibble consisting of the data fields name, along with information about each data field including the data type, a description of the data field, and whether the data field is "searchable" (i.e. can it be used to filter the returned data in an API query)
## Not run: fema_data_fields("FimaNfipClaims") ## End(Not run) ## Not run: fema_data_fields("FimaNfipPolicies") ## End(Not run)
## Not run: fema_data_fields("FimaNfipClaims") ## End(Not run) ## Not run: fema_data_fields("FimaNfipPolicies") ## End(Not run)
Get a tibble of available FEMA data sets
fema_data_sets()
fema_data_sets()
Returns a tibble containing meta data about each data set available through the FEMA API. For more information see the FEMA documentation page: https://www.fema.gov/about/openfema/data-sets.
## Not run: fema_data_sets() ## End(Not run)
## Not run: fema_data_sets() ## End(Not run)
The function allows users to pull data directly from the FEMA API and have it returned as a data frame natively within R.The FEMA API limits a single query to 1000 records, thus for a query resulting in more than 1000 records, an iterative approach is necessary to get all of the records. The function handles this and will, by default, warn the user of how many iterations are needed to get all the records matching their query, letting the user decide choose whether to continue.
open_fema( data_set, top_n = NULL, filters = NULL, select = NULL, ask_before_call = TRUE, file_type = NULL, output_dir = NULL )
open_fema( data_set, top_n = NULL, filters = NULL, select = NULL, ask_before_call = TRUE, file_type = NULL, output_dir = NULL )
data_set |
a character string indicating the data set to get data from |
top_n |
an optional integer value to specify the maximum number of matching records to return |
filters |
an optional list containing values of the data fields contained in the data set to construct filters from |
select |
an optional character vector to specify which data fields to return (default is to return all data fields) |
ask_before_call |
a logical indicating if users should be asked if they would like to proceed when an API call results in a large number of records (default is T). |
file_type |
an optional character string that specifies a file type to save the data as (options are "csv" and "rds"). If a file is specified, the function will not return the api call as a data frame |
output_dir |
an optional character string specifying the directory to save the exported file if the file_type is specified (defaults to working directory). |
Returns a tibble containing the data from the FEMA API.
## Not run: data <- open_fema( data_set = "fimaNfipClaims", top_n = 100, filters = list(countyCode = "10001") ) ## End(Not run)
## Not run: data <- open_fema( data_set = "fimaNfipClaims", top_n = 100, filters = list(countyCode = "10001") ) ## End(Not run)
Returns examples of data field values along with a description of the data field
parameter_values(data_set = NULL, data_field = NULL, message = TRUE)
parameter_values(data_set = NULL, data_field = NULL, message = TRUE)
data_set |
a character vector specifying the data set |
data_field |
a character vector specifying the data field |
message |
a logical value that is TRUE by default. When TRUE, the function will return information as a console message. When set to FALSE, the function will return the same information as a tibble. |
returns a consoles message providing a description of the data field and several example values of the data field within the data set.
## Not run: parameter_values( data_set = "fimaNfipClaims", data_field = "totalBuildingInsuranceCoverage" ) ## End(Not run)
## Not run: parameter_values( data_set = "fimaNfipClaims", data_field = "totalBuildingInsuranceCoverage" ) ## End(Not run)
Get all valid API parameters for a given FEMA data set
valid_parameters(data_set = NULL)
valid_parameters(data_set = NULL)
data_set |
A character string indicating the data set to return valid parameters for |
Returns a tibble of parameter names that can be used to filter an API call for a given open FEMA data set
## Not run: valid_parameters("fimaNfipPolicies") ## End(Not run)
## Not run: valid_parameters("fimaNfipPolicies") ## End(Not run)