Extracts highest posterior density (HPD) uncertainty regions from a BEAST continuous phylogeographic analysis. Each node may have multiple HPD polygons representing the spatial uncertainty of its location estimate.

build_hpd(
  treedata,
  level = "0.80",
  lon = "location1",
  lat = "location2",
  height = "height_median",
  most_recent_sample = NULL,
  debug = getOption("ggphylogeo.debug", FALSE)
)

Arguments

treedata

treedata object with phylogeographic annotations from treeio::read.beast()

level

character HPD level to use (e.g. "0.80" for 80% HPD)

lon

name of longitude coordinate column prefix (default: "location1")

lat

name of latitude coordinate column prefix (default: "location2")

height

column name for node ages (default: "height_median")

most_recent_sample

Date, numeric year, or "YYYY-MM-DD" string for calibrating ages to real dates. If NULL, ages remain as numeric heights.

debug

logical; emit debug messages

Value

A data.frame with columns: node, polygon, lon, lat, age, group; or NULL if no valid HPD polygons found.