knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of addNlcdData is to add varaibles from the National Landcover Database to your data based on nlcd_cell (an identifier for a 30 x 30 m NLCD grid cell) and year (2001, 2006, 2011, or 2016).
Install the development version from GitHub with:
# install.packages("remotes") remotes::install_github("geomarker-io/addNlcdData")
Variables returned for point data include:
impervious
: percent imperviouslandcover_class
: landcover classfication category (broad)landcover
: landcover classification (detailed)green
: TRUE/FALSE if landcover classification in any category except water, ice/snow, developed medium intensity, developed high intensity, rock/sand/clay (based on published definitions)road_type
: impervious descriptor category (or "non-impervious")Variables returned for polygon data include:
impervious
: average percent impervious of all nlcd cells overlapping the polygongreen
: percent of green = TRUE
nlcd cells overlapping polygonprimary_urban
, primary_rural
, secondary_urban
, secondary_rural
, tertiary_urban
, tertiary_rural
, thinned_urban
, thinned_rural
nonroad_urban
, nonroad_rural
, energyprod_urban
, energyprod_rural
: percent of nlcd cells overlapping polygon classified as the corresponding impervious descriptor category nonimpervious
: percent of ncld cells overlapping polygon not classified as any of the impervious descriptior categories Note that the NLCD categories correspond exactly to fraction imperviousness
nlcd category | fraction impervious --------------|-------------------- developed open | < 20% developed low | 20 - 49% developed medium | 50 - 79% developed high | 80 - 100% any other | 0%
The NLCD product values are stored in fst files as "chunks" of the total data and are names like nlcd_chunk_{chunk_number}.fst
. Chunk files will be automatically downloaded to the ./nlcd_fst/
folder in the working directory; the number of chunk files needed depends on the geographic extent of the input spatial data; their sizes vary, but each file is 28.5 MB in size on average (all 1,685 files take about 48 GB on disk). These files were created using code available at https://github.com/geomarker-io/nlcd_raster_to_fst.
Point Data
library(addNlcdData) point_data <- tibble::tribble( ~id, ~lon, ~lat, 51981, -84.69127387, 39.24710734, 77553, -84.47798287, 39.12005904, 52284, -84.47123583, 39.2631309, 96308, -84.41741798, 39.18541228, 78054, -84.41395064, 39.18322447 ) point_data <- get_nlcd_cell_numbers_points(point_data) get_nlcd_data(point_data, product = c("nlcd", "impervious", "imperviousdescriptor"), year = 2016)
Polygon Data
library(sf) library(tigris) options(tigris_class = 'sf')
polygon_data <- tigris::tracts(state = 'oh', county = 'hamilton') %>% dplyr::slice(1:3) %>% dplyr::select(GEOID)
d_poly <- get_nlcd_data_polygons(polygon_data)
d_poly
Points with buffers
get_nlcd_data_point_buffer(point_data, buffer_m = 400)
d_buffer <- get_nlcd_data_point_buffer(point_data, buffer_m = 400)
d_buffer
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.