Interpolation

Example

HowTo: Interpolating gage networks for coastal inundation

One of the most simplistic representations of ocean flooding can be accomplished by taking sea level gages and interpolation those elevations to derive what is sometimes known as a “still-water” surface. This technique, while simplistic, is grounded in these approachable and familiar data and workflows and so makes a good utility to gain broad situation overviews. Indeed, this procedure is loosely implemented in the Easter Region Headquarter CoastalFlood map viewer.

How to

barycentric interpolation

As in Zonal

Reference: The impact of small deviations over large distances

# 1. Setup the data
dist_miles <- 4
dist_feet <- dist_miles * 5280
deviation_feet <- 0.1

df <- data.frame(
  distance = c(0, dist_feet),
  elevation = c(0, deviation_feet)
)

# 2. Create the plot
interp_deviation_plot <- ggplot2::ggplot(df, ggplot2::aes(x = distance, y = elevation)) +
  ggplot2::geom_line(color = "#2c3e50", size = 1.2) +
  ggplot2::geom_area(fill = "#3498db", alpha = 0.2) +
  # Adding points to highlight the start and end
  ggplot2::geom_point(color = "#e74c3c", size = 3) +
  # Formatting labels
  ggplot2::scale_x_continuous(
    label = scales::label_number(suffix = " ft", big.mark = ","),
    breaks = seq(0, dist_feet, length.out = 5)
  ) +
  ggplot2::labs(
    title = "Interpolated Deviation: 0.1 ft over 4 Miles",
    subtitle = paste("Total horizontal distance:", scales::comma(dist_feet), "feet"),
    x = "Horizontal Distance (Feet)",
    y = "Vertical Deviation (Feet)"
  ) +
  ggplot2::theme_minimal() +
  # Note: In a true 1:1 scale, this line would look perfectly flat.
  # We use a free scale here to make the deviation visible.
  ggplot2::annotate("text", x = dist_feet * 0.8, y = 0.02, 
                    label = paste("Slope:", round(deviation_feet/dist_feet * 100, 5), "%"),
                    color = "darkred")
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
interp_deviation_plot