Skip to contents

Generates a plot of a DEM clipped to an Area of Interest (AOI) and saves it as a JPG file.

Usage

single_map(aoi, dem, output_file = "dem_plot.jpg", title = "DEM over AOI")

Arguments

aoi

An `sf` object representing the Area of Interest.

dem

A `SpatRaster` object from the `terra` package representing the DEM.

output_file

The path to save the output map image.

title

The title for the map.

Value

A ggplot object.

Examples

if (FALSE) { # \dontrun{
library(sf)
library(terra)

# Define a dummy area of interest
aoi <- st_as_sf(data.frame(
  id = 1,
  geometry = st_sfc(st_polygon(list(rbind(
    c(77.0, 28.0), c(78.0, 28.0), c(78.0, 29.0), c(77.0, 29.0), c(77.0, 28.0)
  ))))
), crs = 4326)

# --- Example 1: Map with Simulated DEM ---
dem_fake <- rast(nrows = 100, ncols = 100, xmin = 76, xmax = 79, ymin = 27, ymax = 30, vals = runif(10000, 200, 800))
crs(dem_fake) <- "EPSG:4326"

single_map(
  aoi = aoi,
  dem = dem_fake,
  output_file = "output/simulated_dem_map.jpg",
  title = "Simulated Elevation"
)
} # }