Install
openclaw skills install @ruiduobao/worldpop-populationSearch and download WorldPop population grid datasets (GeoTIFF) by country and year. Supports population density, births, age structures, and more. No API key required.
openclaw skills install @ruiduobao/worldpop-populationSearch 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.
# 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
pip install requests>=2.28.0 tqdm
# Or: pip install -r scripts/requirements.txt
search| Argument | Required | Default | Description |
|---|---|---|---|
--country | No* | — | Country name (e.g., "China") |
--code | No* | — | ISO 3166-1 alpha-3 code (e.g., "CHN") |
--year | No | — | Filter by year (2000-2020) |
--type | No | — | Dataset type filter |
--json | No | false | Output as JSON |
* At least one of --country or --code is recommended.
download| Argument | Required | Default | Description |
|---|---|---|---|
--id | Yes | — | Dataset ID (from search results) |
--output | Yes | — | Output GeoTIFF path |
list-countries| Argument | Required | Default | Description |
|---|---|---|---|
--json | No | false | Output as JSON |
--type Values| Type | Description |
|---|---|
population | Population density (persons per pixel) |
births | Number of births |
age_structures | Age structure grids |
contraceptive_use | Contraceptive use estimates |
poverty | Poverty indicators |
urban_change | Urban change classification |
gender | Gender-related indicators |
disability | Disability prevalence |
--check-size before downloading large datasets[
{
"id": 25,
"title": "China Population 2020",
"year": 2020,
"country": "CHN",
"resolution": "100m",
"type": "population",
"url": "https://www.worldpop.org/..."
}
]
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}
}
plt.imshow(np.log1p(data), cmap='hot')rasterio.plot.show() for quick visualizationcontextily basemaps for context| Error | Cause | Solution |
|---|---|---|
ConnectionError | Network issue | Check internet, retry |
HTTP 429 | Rate limit | Wait 60s, retry |
ValueError | Invalid input | Check parameter format |
| Empty output | No data | Try different parameters |
ModuleNotFoundError | Missing dep | Run pip install |
| Large file size | High resolution | Use 1km datasets or subset by bbox |
| Download timeout | Slow connection | Retry or use smaller dataset |
# 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
# .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
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)
raster2pgsql -s 4326 -I -C pop_CHN_2020.tif public.worldpop | psql -d gis_db
sleep 2 between downloads to respect rate limits--type population for total pop, --type population_density for per-km²从 WorldPop 搜索和下载高分辨率人口栅格数据(GeoTIFF)。 包括人口密度(100m)、出生、年龄结构等数据集。无需 API 密钥。
# 搜索中国人口数据
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
--type 值| 类型 | 描述 |
|---|---|
population | 人口密度(每像素人数) |
births | 出生人数 |
age_structures | 年龄结构栅格 |
contraceptive_use | 避孕药具使用估计 |
poverty | 贫困指标 |
urban_change | 城市变化分类 |
gender | 性别相关指标 |
disability | 残疾患病率 |
--check-size 查看大小[
{
"id": 25,
"title": "China Population 2020",
"year": 2020,
"country": "CHN",
"resolution": "100m",
"type": "population",
"url": "https://www.worldpop.org/..."
}
]
如果发表使用 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 数据集或按边界截取 |
| 下载超时 | 网络慢 | 重试或使用更小的数据集 |