knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

addNlcdData

R build status R-CMD-check

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).

Installation

Install the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("geomarker-io/addNlcdData")

NLCD data details

NLCD grid chunk files

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.

Examples

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


geomarker-io/addNlcdData documentation built on Feb. 19, 2023, 1:42 p.m.