Clip raster to conservation district boundary
Examples
if (FALSE) { # \dontrun{
# Download CDL raster for specific year and state
cdl_raster <- terra::rast("path/to/cdl_raster.tif")
# Load conservation district boundary
cd_boundary <- sf::st_read("path/to/conservation_district.shp")
# Clip the raster to the conservation district
clipped_raster <- clip_raster_to_cd("path/to/cdl.tif", "Columbia")
# Plot the result
terra::plot(clipped_raster)
# Save the clipped raster
terra::writeRaster(
clipped_raster,
filename = "cropland_data_layer_2024.tif",
overwrite = TRUE,
filetype = "GTiff",
gdal = c("COMPRESS=LZW")
)
} # }
