Geoskill: WorldPop Population

Search and download WorldPop high-resolution population and demographic GeoTIFF datasets by country, year, and type without an API key.

ruiduobao

@ruiduobao

What This Skill Does

Command-line tool to search and download WorldPop population grid datasets (GeoTIFF) by country and year. Supports population density, births, age structures, and other demographic indicators without requiring an API key.

Replaces manual browsing and downloading from the WorldPop website by providing a scriptable CLI for searching and fetching high-resolution population grids.

When to Use It

  • Download population density grids for a specific country and year
  • Search for available WorldPop datasets by country name or ISO code
  • Fetch age structure or birth rate grids for demographic analysis
  • List all countries with available WorldPop data for project scoping
  • Integrate population data downloads into automated research pipelines

Install

$ openclaw skills install @ruiduobao/worldpop-population

WorldPop Population

Search and download high-resolution population grid data from WorldPop. Datasets include population density (100m), births, age structures, contraceptive use, and more. No API key required.

Features

  • Search datasets by country, year, or type
  • Download population grids as GeoTIFF
  • List all available countries
  • JSON output for scripting

Usage

# Search for China population data
python scripts\worldpop-population.py search --country China --year 2020

# Search by ISO code
python scripts\worldpop-population.py search --code CHN --type population

# Download a dataset by ID
python scripts\worldpop-population.py download --id 25 --output pop_chn_2020.tif

# List available countries
python scripts\worldpop-population.py list-countries

Installation

pip install requests>=2.28.0 tqdm
# Or: pip install -r scripts/requirements.txt

Parameters

search

ArgumentRequiredDefaultDescription
--countryNo*Country name (e.g., "China")
--codeNo*ISO 3166-1 alpha-3 code (e.g., "CHN")
--yearNoFilter by year (2000-2020)
--typeNoDataset type filter
--jsonNofalseOutput as JSON

* At least one of --country or --code is recommended.

download

ArgumentRequiredDefaultDescription
--idYesDataset ID (from search results)
--outputYesOutput GeoTIFF path

list-countries

ArgumentRequiredDefaultDescription
--jsonNofalseOutput as JSON

Data Source

  • API: WorldPop REST API
  • Coverage: Global (100+ countries)
  • Resolution: 100m or 1km depending on dataset
  • Time range: 2000-2020
  • License: CC BY 4.0 (most datasets)
  • CRS: WGS84 (EPSG:4326)
  • Data type: float32
  • Nodata value: -99999

Valid --type Values

TypeDescription
populationPopulation density (persons per pixel)
birthsNumber of births
age_structuresAge structure grids
contraceptive_useContraceptive use estimates
povertyPoverty indicators
urban_changeUrban change classification
genderGender-related indicators
disabilityDisability prevalence

File Size Estimates

  • ~400MB per country at 100m resolution (uncompressed GeoTIFF)
  • ~40MB per country at 1km resolution
  • Use --check-size before downloading large datasets

Example Search Output

[
  {
    "id": 25,
    "title": "China Population 2020",
    "year": 2020,
    "country": "CHN",
    "resolution": "100m",
    "type": "population",
    "url": "https://www.worldpop.org/..."
  }
]

Choosing Between Datasets

  • 100m resolution: Best for local/regional analysis, urban planning
  • 1km resolution: Suitable for national/regional overviews, faster processing
  • Population density: Most commonly used; persons per pixel
  • Births: Useful for health service planning
  • Age structures: Demographic analysis, dependency ratios

Citation

If you use WorldPop data in publications, please cite:

@article{worldpop2018,
  title = {WorldPop, open data for spatial demography},
  author = {Tatem, Andrew J. and others},
  journal = {Scientific Data},
  volume = {5},
  pages = {180004},
  year = {2018},
  doi = {10.1038/sdata.2018.4}
}

Visualization

  • Plot population density with log scale: plt.imshow(np.log1p(data), cmap='hot')
  • Use rasterio.plot.show() for quick visualization
  • Create choropleth maps by aggregating to administrative boundaries
  • Overlay with contextily basemaps for context

Troubleshooting

ErrorCauseSolution
ConnectionErrorNetwork issueCheck internet, retry
HTTP 429Rate limitWait 60s, retry
ValueErrorInvalid inputCheck parameter format
Empty outputNo dataTry different parameters
ModuleNotFoundErrorMissing depRun pip install
Large file sizeHigh resolutionUse 1km datasets or subset by bbox
Download timeoutSlow connectionRetry or use smaller dataset

Advanced Usage

Batch Country Download

# Download population for multiple countries
for iso in CHN IND USA BRA; do
  python scripts\worldpop-population.py download     --iso $iso --type population --year 2020     --output pop_${iso}_2020.tif
  sleep 2
done

CI/CD Integration (GitHub Actions)

# .github/workflows/update-population.yml
name: Update Population Data
on:
  schedule:
    - cron: '0 0 1 1 *'  # Yearly
jobs:
  download:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.11'
      - run: pip install requests tqdm
      - run: |
          python scripts\worldpop-population.py download \
            --iso CHN --type population --year 2020 \
            --output data/china_pop2020.tif

Windowed Reading for Large Files

import rasterio
from rasterio.windows import Window
# Read only a subset to avoid loading 400MB into memory
with rasterio.open('pop_CHN_2020.tif') as src:
    window = Window(0, 0, 1000, 1000)  # top-left 1000x1000 pixels
    subset = src.read(1, window=window)

PostgreSQL/PostGIS Raster Import

raster2pgsql -s 4326 -I -C pop_CHN_2020.tif public.worldpop | psql -d gis_db

Performance Tips

  • 100m files are ~400MB; use windowed reading for subset analysis
  • Add sleep 2 between downloads to respect rate limits
  • Use --type population for total pop, --type population_density for per-km²
  • NoData value is -99999; mask before arithmetic operations

中文说明

WorldPop 搜索和下载高分辨率人口栅格数据(GeoTIFF)。 包括人口密度(100m)、出生、年龄结构等数据集。无需 API 密钥。

功能

  • 按国家、年份或类型搜索数据集
  • 下载人口栅格为 GeoTIFF
  • 列出所有可用国家
  • JSON 输出支持脚本调用

使用方法

# 搜索中国人口数据
python scripts\worldpop-population.py search --country China --year 2020

# 按 ISO 代码搜索
python scripts\worldpop-population.py search --code CHN --type population

# 按 ID 下载数据集
python scripts\worldpop-population.py download --id 25 --output pop_chn_2020.tif

# 列出可用国家
python scripts\worldpop-population.py list-countries

数据来源

  • API: WorldPop REST API
  • 覆盖范围: 全球(100+ 国家)
  • 分辨率: 100m 或 1km(取决于数据集)
  • 时间范围: 2000-2020
  • 许可证: CC BY 4.0(大多数数据集)
  • 坐标系: WGS84 (EPSG:4326)
  • 数据类型: float32
  • 无数据值: -99999

有效的 --type

类型描述
population人口密度(每像素人数)
births出生人数
age_structures年龄结构栅格
contraceptive_use避孕药具使用估计
poverty贫困指标
urban_change城市变化分类
gender性别相关指标
disability残疾患病率

文件大小估计

  • 100m 分辨率:每个国家约 400MB(未压缩 GeoTIFF)
  • 1km 分辨率:每个国家约 40MB
  • 下载大数据集前可使用 --check-size 查看大小

搜索结果示例

[
  {
    "id": 25,
    "title": "China Population 2020",
    "year": 2020,
    "country": "CHN",
    "resolution": "100m",
    "type": "population",
    "url": "https://www.worldpop.org/..."
  }
]

数据集选择指南

  • 100m 分辨率: 适合局地/区域分析、城市规划
  • 1km 分辨率: 适合国家/区域概览,处理更快
  • 人口密度: 最常用;每像素人数
  • 出生人数: 适用于卫生服务规划
  • 年龄结构: 人口统计分析、抚养比

引用格式

如果发表使用 WorldPop 数据,请引用:

@article{worldpop2018,
  title = {WorldPop, open data for spatial demography},
  author = {Tatem, Andrew J. and others},
  journal = {Scientific Data},
  volume = {5},
  pages = {180004},
  year = {2018},
  doi = {10.1038/sdata.2018.4}
}

可视化

  • 使用对数比例绘制人口密度: plt.imshow(np.log1p(data), cmap='hot')
  • 使用 rasterio.plot.show() 快速可视化
  • 聚合到行政区划创建等值区域图
  • 使用 contextily 底图叠加上下文

故障排除

错误原因解决方案
ConnectionError网络问题检查网络,重试
HTTP 429速率限制等待 60 秒后重试
ValueError无效输入检查参数格式
空输出无数据尝试不同参数
ModuleNotFoundError缺少依赖运行 pip install
文件过大高分辨率使用 1km 数据集或按边界截取
下载超时网络慢重试或使用更小的数据集

Top skills in this category