mn_zonal: Summarise a raster over map units

View source: R/layers-raster.R

mn_zonalR Documentation

Summarise a raster over map units

Description

Adds a column to x with a summary of the raster cells in each unit, for example the total population of every soum or the mean elevation of every aimag.

Usage

mn_zonal(
  r,
  x = NULL,
  fun = c("sum", "mean", "min", "max", "median"),
  name = "value"
)

Arguments

r

A terra SpatRaster (one layer), such as from mn_population().

x

An sf object of polygons, such as mn_soums(). Defaults to the aimags.

fun

Summary function name: "sum" (default), "mean", "min", "max" or "median".

name

Name of the new column.

Value

x with a new column.

See Also

Other raster layers: mn_elevation(), mn_landcover(), mn_population()

Examples


soum_pop <- mn_zonal(mn_population(2025), mn_soums(), name = "population")
mn_map(soum_pop, fill = population / area_km2, trans = "log10")


mongolmaps documentation built on Oct. 10, 2026, 5:08 p.m.