plot_ntl_map: Plot a nighttime lights raster map

View source: R/plot.R

plot_ntl_mapR Documentation

Plot a nighttime lights raster map

Description

Renders a single SpatRaster as a map. Two palettes are available:

Usage

plot_ntl_map(
  raster,
  polygons = NULL,
  title = "Nighttime lights",
  caption = NULL,
  palette = c("glow", "bhuvan"),
  dark = TRUE,
  limits = NULL
)

Arguments

raster

A single-layer SpatRaster. Pass one element from the list returned by ntl_download() or bhuvan_raster().

polygons

Optional sf object for boundary overlay.

title

Plot title. Default "Nighttime lights".

caption

Optional caption string.

palette

One of "glow" (default) or "bhuvan".

dark

Logical. If TRUE, the plot background is ⁠#080c14⁠ (deep navy) and text is light. Ignored when palette = "bhuvan" (always dark bg). Default TRUE.

limits

Numeric vector of length 2 for the continuous scale. Only used when palette = "glow". NULL uses the raster min/max. Set explicitly when comparing multiple panels on the same scale.

Details

  • "glow" (default): continuous dark-olive-to-cream-white ramp modelled on the NASA Black Marble composite. Suited to dark backgrounds and multi-panel year comparisons.

  • "bhuvan": 4-class categorical legend matching the Bhuvan portal: black (< 5 nW/cm2/sr), dark blue-grey (5-25), cream (26-200), red (> 200).

Value

A ggplot2 object.

Examples


r <- terra::rast(
  nrows = 20, ncols = 20, xmin = 77, xmax = 78, ymin = 28, ymax = 29,
  crs = "EPSG:4326", vals = seq_len(400) / 2
)
plot_ntl_map(r)
plot_ntl_map(r, palette = "bhuvan")


lightson documentation built on Nov. 3, 2026, 5:07 p.m.