worldclim-extract

v1.0.0

Extract bioclimatic variables (BIO1-BIO19) from WorldClim GeoTIFF rasters using sample coordinates (longitude/latitude). Supports automatic download of World...

0· 22·0 current·0 all-time
byDong Zhao@zd200572

Install

OpenClaw Prompt Flow

Install with OpenClaw

Best for remote or guided setup. Copy the exact prompt, then paste it into OpenClaw for zd200572/worldclim-extract.

Previewing Install & Setup.
Prompt PreviewInstall & Setup
Install the skill "worldclim-extract" (zd200572/worldclim-extract) from ClawHub.
Skill page: https://clawhub.ai/zd200572/worldclim-extract
Keep the work scoped to this skill only.
After install, inspect the skill metadata and help me finish setup.
Required binaries: python3
Use only the metadata you can verify from ClawHub; do not invent missing requirements.
Ask before making any broader environment changes.

Command Line

CLI Commands

Use the direct CLI path if you want to install manually and keep every step visible.

OpenClaw CLI

Bare skill slug

openclaw skills install worldclim-extract

ClawHub CLI

Package manager switcher

npx clawhub@latest install worldclim-extract
Security Scan
VirusTotalVirusTotal
Pending
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name/description, SKILL.md, and the included Python script all implement the same functionality: reading CSV/XLSX coordinates, (optionally) downloading WorldClim zip files from geodata.ucdavis.edu, extracting .tif rasters, sampling with rasterio, and writing outputs. Required binary (python3) is proportional.
Instruction Scope
Runtime instructions and the script only read the provided input file(s), download and extract WorldClim data to the specified cache directory, and write outputs. There are no instructions to read unrelated system files, environment variables, or to transmit data to unknown endpoints; the only network access is to the documented UC Davis WorldClim host.
Install Mechanism
No install spec is provided (instruction-only plus a script). Recommended package installs use pip for rasterio/pandas/openpyxl — expected for this task. Downloads of raster data come from a well-known WorldClim host (geodata.ucdavis.edu) and are extracted into a local cache directory.
Credentials
The skill requests no environment variables or credentials. It only requires local filesystem access to read input and write cache/output files, which is necessary for its stated function.
Persistence & Privilege
always is false and the skill does not modify other skills or agent configuration. It persists downloaded data to a local cache directory (user-configurable) — expected behavior for large raster datasets.
Assessment
This skill appears coherent and implements exactly what it claims. Before running: 1) ensure you have the required Python packages (rasterio can require system libs; consider using conda or a virtualenv); 2) confirm you have sufficient disk space (downloads range ~48–650 MB per resolution and expand when unzipped); 3) note the default cache is ./worldclim_data — change it if you prefer a different location; 4) verify the download URL (https://geodata.ucdavis.edu/climate/worldclim/2_1/base) if operating under strict network policies; and 5) run in an isolated environment if you need extra caution. If you see unexpected network calls or file accesses beyond the cache/input/output paths, stop and review the script first.

Like a lobster shell, security has layers — review code before you run it.

Runtime requirements

🌍 Clawdis
Binspython3
latestvk97bns9b9dc5szczs74f5qk3y985qbq2
22downloads
0stars
1versions
Updated 7h ago
v1.0.0
MIT-0

Version Compatibility

Reference examples tested with: Python 3.10+, rasterio 1.4+, pandas 2.0+

Before using code patterns, verify installed versions match. If versions differ:

  • pip show rasterio pandas openpyxl

If code throws ImportError, install missing packages:

pip install rasterio pandas openpyxl

Overview

WorldClim provides global climate data as GeoTIFF raster files. Each .tif file is a grid covering the entire Earth, where each grid cell stores a climate value (e.g., temperature in °C or precipitation in mm). This skill automates the process of extracting climate values for specific geographic coordinates.

How It Works

  1. Input: Excel or CSV file containing sample coordinates (longitude, latitude)
  2. Data: WorldClim 2.1 bioclimatic GeoTIFF files (19 BIO variables, 1970-2000 average)
  3. Process: For each coordinate, find the corresponding grid cell and read its value
  4. Output: Original data plus extracted climate columns appended

Grid Resolution

ResolutionCell SizeApprox. AreaFile Size
10m0.167°~18.5 km²~48 MB zip
5m0.083°~9.3 km²~170 MB zip
2.5m0.042°~4.6 km²~650 MB zip

Default: 10m — sufficient for most ecological/population genetics studies.

Quick Start

Using the CLI Script

A reusable Python script is provided at {baseDir}/extract_worldclim.py:

# Extract BIO1 (annual mean temp) and BIO12 (annual precipitation) — default
python3 {baseDir}/extract_worldclim.py \
  -i samples.xlsx \
  -o samples_with_climate.xlsx

# Extract all 19 bioclimatic variables
python3 {baseDir}/extract_worldclim.py \
  -i samples.xlsx \
  -o samples_all_bio.xlsx \
  --bios 1-19

# Extract specific variables with custom column names
python3 {baseDir}/extract_worldclim.py \
  -i coords.csv \
  -o result.xlsx \
  --bios 1,5,6,12,13 \
  --res 2.5m \
  --lon longitude \
  --lat latitude

Using Python Directly

For custom integration or programmatic use:

import pandas as pd
import rasterio

def extract_bio(tif_path, lon, lat):
    """Extract a single value from a GeoTIFF at given coordinates."""
    with rasterio.open(tif_path) as src:
        value = next(src.sample([(lon, lat)]))[0]
    return value

# Read sample coordinates
df = pd.read_excel("samples.xlsx")
coords = list(zip(df["经度"], df["纬度"]))

# Extract BIO1 (Annual Mean Temperature)
with rasterio.open("wc2.1_10m_bio_1.tif") as src:
    df["年均温度_C"] = [v[0] for v in src.sample(coords)]

# Extract BIO12 (Annual Precipitation)
with rasterio.open("wc2.1_10m_bio_12.tif") as src:
    df["年降水量_mm"] = [v[0] for v in src.sample(coords)]

df.to_excel("samples_with_climate.xlsx", index=False)

WorldClim Data Download

Automatic (script handles it)

The CLI script auto-downloads data on first run to the --cache directory (default: ./worldclim_data).

Manual Download

If automatic download fails (e.g., network issues):

# 10m resolution (~48 MB)
curl -O https://geodata.ucdavis.edu/climate/worldclim/2_1/base/wc2.1_10m_bio.zip
unzip wc2.1_10m_bio.zip -d ./worldclim_data/

# 2.5m resolution (~650 MB)
curl -O https://geodata.ucdavis.edu/climate/worldclim/2_1/base/wc2.1_2.5m_bio.zip
unzip wc2.1_2.5m_bio.zip -d ./worldclim_data/

BIO Variable Reference

BIONameUnitDescription
BIO1Annual Mean Temperature°C年均温度
BIO2Mean Diurnal Range°C昼夜温差月均值
BIO3Isothermality%等温性 (BIO2/BIO7 × 100)
BIO4Temperature SeasonalitySD × 100温度季节性
BIO5Max Temp of Warmest Month°C最暖月最高温
BIO6Min Temp of Coldest Month°C最冷月最低温
BIO7Temperature Annual Range°C年温度范围 (BIO5−BIO6)
BIO8Mean Temp of Wettest Quarter°C最湿季均温
BIO9Mean Temp of Driest Quarter°C最干季均温
BIO10Mean Temp of Warmest Quarter°C最暖季均温
BIO11Mean Temp of Coldest Quarter°C最冷季均温
BIO12Annual Precipitationmm年降水量
BIO13Precipitation of Wettest Monthmm最湿月降水量
BIO14Precipitation of Driest Monthmm最干月降水量
BIO15Precipitation SeasonalityCV降水季节性
BIO16Precipitation of Wettest Quartermm最湿季降水量
BIO17Precipitation of Driest Quartermm最干季降水量
BIO18Precipitation of Warmest Quartermm最暖季降水量
BIO19Precipitation of Coldest Quartermm最冷季降水量

Data Source: WorldClim 2.1 (1970-2000, 30-year average)

Input Format Requirements

Required Columns

  • Longitude column: Decimal degrees, range [-180, 180]. Default column name: 经度 (override with --lon)
  • Latitude column: Decimal degrees, range [-90, 90]. Default column name: 纬度 (override with --lat)

Supported Input Formats

  • .xlsx — Excel workbook (recommended, handles Chinese headers well)
  • .csv — Comma-separated values

Common Issues

IssueCauseSolution
Coordinates read as textHidden special characters (e.g., \xa0 non-breaking space)Script auto-cleans with pd.to_numeric(errors='coerce'); check for NA after conversion
Negative longitudes rejectedUsing East/West format instead of decimalConvert to decimal: 东经 117° → 117.0; 西经 117° → -117.0
Missing extracted valuesCoordinate falls in ocean or outside raster boundsCheck coordinate validity; WorldClim covers land globally

Output Format

The output file contains all original columns plus extracted BIO columns:

名称    经度        纬度        年均温度_C    年降水量_mm
NFAL10  117.214052  31.270421   16.15        1325.0
NFBJ1   116.591445  40.032115   11.88        542.0

Using R (terra) for Cross-Validation

If you need to validate results with R:

library(terra)

# Read raster stack
bio <- rast(list.files("./worldclim_data", pattern = "\\.tif$", full.names = TRUE))

# Read and clean coordinates
pts <- readxl::read_excel("samples.xlsx")
pts$经度 <- as.numeric(gsub("\\s+", "", pts$经度))  # Remove hidden spaces
pts$纬度 <- as.numeric(pts$纬度)
pts <- pts[!is.na(pts$经度) & !is.na(pts$纬度), ]

# Extract
v <- vect(pts, geom = c("经度", "纬度"), crs = "EPSG:4326")
result <- extract(bio, v)
write.csv(cbind(pts, result[, -1]), "output.csv", row.names = FALSE)

Note: R's as.numeric() is stricter than Python's pandas and may fail on hidden whitespace. Always clean coordinates before conversion.

Decision Tree

Need to extract climate data for sample coordinates?
├── Have coordinates in Excel/CSV?
│   └── Use the CLI script: python3 extract_worldclim.py -i input.xlsx -o output.xlsx
├── Need only temperature and precipitation?
│   └── Default: --bios 1,12 (no need to specify)
├── Need all 19 bioclimatic variables?
│   └── Use: --bios 1-19
├── Need higher spatial resolution?
│   ├── ~9 km cells → --res 5m
│   └── ~4.6 km cells → --res 2.5m
└── Need to integrate into a Python pipeline?
    └── Use the direct Python code pattern with rasterio.sample()

Related Skills

  • bio-geo-data — For general geospatial data operations
  • bio-read-sequences — For biological sequence file parsing
  • bio-batch-processing — For processing multiple files in batch

Comments

Loading comments...