
Reclassify CDL raster to 7 generalized NLCD-style land cover groups
Source:R/clip_raster_to_cd.R, R/reclassify_raster.R
reclassify_raster.RdReclassify CDL raster to 7 generalized NLCD-style land cover groups
Value
A new SpatRaster with values 1–7 representing generalized land cover categories
and a category table for labeling and mapping.
A new SpatRaster with values 1–7 representing generalized land cover categories
and a category table for labeling and mapping.
References
https://www.nass.usda.gov/Research_and_Science/Cropland/metadata/meta.php
https://www.nass.usda.gov/Research_and_Science/Cropland/metadata/meta.php
Examples
if (FALSE) { # \dontrun{
# Reclassify a CDL raster
cdl_raster <- terra::rast("path/to/cdl.tif")
reclassified <- reclassify_raster(cdl_raster)
# Define colors for visualization
category_colors <- c(
"Row Crops" = "#FFFF64", # Cropland yellow
"Non-Crop Natural" = "#DCD939", # Grassland/herbaceous
"Specialty Crops" = "#A8E6A0", # Orchard/vineyard
"Developed" = "#FF0000", # High intensity development
"Water" = "#476BA1", # Open water
"NLCD Natural" = "#397D49", # Evergreen forest
"Other/No Data" = "#D3D3D3" # No data
)
# Create leaflet map
leaflet() %>%
addTiles() %>%
leaflet::addRasterImage(reclassified, project = TRUE, opacity = 0.7) %>%
addLegend(
position = "bottomright",
colors = category_colors,
labels = names(category_colors),
title = "Land Cover 2024",
opacity = 1
)
} # }
if (FALSE) { # \dontrun{
# Reclassify a CDL raster
cdl_raster <- terra::rast("path/to/cdl.tif")
reclassified <- reclassify_raster(cdl_raster)
# Define colors for visualization
category_colors <- c(
"Row Crops" = "#FFFF64", # Cropland yellow
"Non-Crop Natural" = "#DCD939", # Grassland/herbaceous
"Specialty Crops" = "#A8E6A0", # Orchard/vineyard
"Developed" = "#FF0000", # High intensity development
"Water" = "#476BA1", # Open water
"NLCD Natural" = "#397D49", # Evergreen forest
"Other/No Data" = "#D3D3D3" # No data
)
# Create leaflet map
leaflet() %>%
addTiles() %>%
leaflet::addRasterImage(reclassified, project = TRUE, opacity = 0.7) %>%
addLegend(
position = "bottomright",
colors = category_colors,
labels = names(category_colors),
title = "Land Cover 2024",
opacity = 1
)
} # }