HEC-RAS workflows commonly begin with paired depth and velocity GeoTIFFs. The package includes a compact pair derived from the 31 May 2022 HEC-RAS model output used by Cordero and Harris (Preprint). These are real hydraulic surfaces from the confluence of the Big Blue and Kansas Rivers near Manhattan, Kansas, rather than synthetic cells.
The source rasters were cropped to the detailed manuscript-map extent, aggregated from 3-foot to 18-foot cells, and converted from feet and feet per second to metres and metres per second. The raster coordinates remain in the source project’s documented NAD 1983 (CORS96) StatePlane Kansas North system.
The helper can return either installed GeoTIFF paths or loaded rasters:
## [1] "big_blue_kansas_depth_m.tif" "big_blue_kansas_velocity_m_s.tif"
## [1] TRUE
old_par <- graphics::par(mfrow = c(1, 2), mar = c(1, 1, 3, 4))
terra::plot(h$depth, col = grDevices::hcl.colors(40, "Blues 3"),
main = "Depth (m)", axes = FALSE)
terra::plot(h$velocity, col = grDevices::hcl.colors(40, "YlOrRd"),
main = "Velocity (m/s)", axes = FALSE)Inspect units, dry-cell encoding, CRS, extent, resolution, origin, and dimensions before classifying any HEC-RAS export. The example is already in the metric hydraulic units required by the default scheme.
classes <- classify_mesohabitat_raster(h$depth, h$velocity)
class_colors <- mesohabitat_palette()
plot_mesohabitat(
classes,
main = "Big Blue-Kansas Rivers mesohabitats — 31 May 2022",
axes = FALSE,
palette = class_colors
)The white background is outside the HEC-RAS wetted surface. Class IDs describe depth-velocity combinations; they are not habitat-quality scores.
An AOI can be a SpatVector or a supported vector path.
By default both crop and polygon mask are applied. This reproducible
rectangle selects the central part of the included river sample:
e <- terra::ext(h$depth)
dx <- terra::xmax(e) - terra::xmin(e)
dy <- terra::ymax(e) - terra::ymin(e)
aoi <- terra::as.polygons(
terra::ext(
terra::xmin(e) + 0.18 * dx, terra::xmax(e) - 0.18 * dx,
terra::ymin(e) + 0.12 * dy, terra::ymax(e) - 0.12 * dy
),
crs = terra::crs(h$depth)
)
cropped <- classify_mesohabitat_raster(h$depth, h$velocity, aoi = aoi)
plot_mesohabitat(
cropped, axes = FALSE, palette = class_colors
)When input geometry differs, align = "velocity_to_depth"
uses bilinear interpolation to project or resample continuous velocity
to the depth template. Assigning a known missing CRS with
assume_crs describes existing coordinates; it does not move
them.
For multiple dates, use unique matching names rather than relying on file order. Output can be written to a GeoTIFF with an accompanying class-table CSV:
series <- classify_mesohabitat_series(
list(`2022-05-31` = h$depth),
list(`2022-05-31` = h$velocity)
)
out <- file.path(tempdir(), "hecras_mesohabitat.tif")
write_mesohabitat(series[[1]], out, sidecar = TRUE, overwrite = TRUE)Determine how dry HEC-RAS cells are represented before choosing
dry_threshold; the package does not silently redefine zero
depth.