Gallery

World population

  • Data source: global2 from WorldPop
  • Raw data contains population counts per (approximately) one squared kilometer.
  • Aggregated to 64 km2, both for computational and practical reasons (otherwise it would be far too spiky).
  • Used software: tmap.mapgl

R code

library(tmap)
library(tmap.mapgl)
library(terra)
# downloaded from WorldPop
# https://hub.worldpop.org/geodata/summary?id=80031
x_1km = rast("~/Downloads/global_pop_2025_CN_1km_R2025A_UA_v1.tif")
x_16km = terra::aggregate(x_1km, fact = 16, fun = sum, na.rm = TRUE)
x_64km = terra::aggregate(x_16km, fact = 4, fun = sum, na.rm = TRUE)
names(x_64km) = "pop"
tm_shape(x_64km) + 
  tm_polygons_3d(
    height = "pop",
    fill = "pop",
    fill.scale = tm_scale_intervals(values = "-ocean.thermal", style = "kmeans"),
    fill.legend = tm_legend_hide())

See full screen