Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

02 — Data clean: predictor layers on their native grids (Colombia window)

LifeWatch ERIC

Turns the raw downloads of 01b into analysis-ready predictor layers for the independent random-forest pipeline. Coarse layers stay on their native lon/lat grids (written as NetCDF); 02b_feature_extraction samples them at 30 m pixel centres (nearest neighbour). The 30 m Hansen layers are only mosaicked (GDAL VRT), because the focal statistics are computed per tile in 02b.

Output (data/clean/)WhatChoice (see docs/deviations.md)
bioclim_pca.nc, bioclim_pca_summary.csvPC1–PC5 of the 19 WorldClim bioclim variablesPCA re-derived on 1 M random global land points; centring and scaling chosen by matching Supp. Table 1
soil_0_30cm.ncOCDENS, PHIHOX, top 30 cmtrapezoidal depth weighting of 0, 5, 15, 30 cm
landcover.ncESA CCI LC 1992 / 1999 / 2000 / 2015 in 11 classes, cropland density (5 km), distance to urban31 → 11 class mapping defined here
npp.nc, roads.nc, burned.ncNPP mean 2000–2015; GRIP4 road density; fraction of months burned 2001–2017—
biomes_colombia.parquetRESOLVE 2017 biomes clipped to the windowstudy biomes 1, 2, 3
hansen_<layer>.vrt, srtm.vrtmosaics—

Smoke mode (SMOKE=1): outputs go to data/clean_smoke/; the PCA sample is 20,000 points drawn inside the smoke sub-window only (tests the code path, not the science).

window (np.float64(-83.0), np.float64(-5.0), np.float64(-66.0), np.float64(17.0))

1. Bioclim PCA (WorldClim v2.1, 30 s)

Paper (Methods): 1 million random points within land areas, the 19 values per point, R prcomp, then predict.prcomp on all pixels; first five components. Centring / scaling is not reported, and Supp. Table 1 reports only component standard deviations. We sample 1,000,000 points uniformly by area on the sphere (latitude = arcsin(U(-1, 1))), keep those on a valid WorldClim pixel, and fit both prcomp variants (centre only = R default; centre + scale). The variant whose component SDs match Supp. Table 1 is used.

1000000 points; any NaN: False
component  supp_table1_sd  centre_only_sd  centre_scale_sd  centre_only_cumprop  centre_scale_cumprop
      PC1           780.4           893.2            3.103               0.7913                0.5069
      PC2             362             387            2.069               0.9399                0.7323
      PC3           146.8           184.4            1.393               0.9736                0.8344
      PC4           103.1             131             1.11               0.9906                0.8993
      PC5            59.7           76.16           0.8074               0.9964                0.9336
mean |log SD ratio| vs Supp. Table 1: {'centre_only': 0.18261746757673472, 'centre_scale': 4.836777161959005} -> using centre_only
<xarray.Dataset> Size: 108MB
Dimensions:  (lat: 2640, lon: 2040)
Coordinates:
  * lat      (lat) float64 21kB 17.0 16.99 16.98 16.97 ... -4.979 -4.988 -4.996
  * lon      (lon) float64 16kB -83.0 -82.99 -82.98 ... -66.02 -66.01 -66.0
Data variables:
    pc1      (lat, lon) float32 22MB ...
    pc2      (lat, lon) float32 22MB ...
    pc3      (lat, lon) float32 22MB ...
    pc4      (lat, lon) float32 22MB ...
    pc5      (lat, lon) float32 22MB ...
Attributes:
    pca_variant:  centre_only
    source:       WorldClim v2.1 30 s bioclim; PCA on 1e6 global land points

1b. Sensitivity check (not a fix): CHELSA v2.1 bioclim, 1981–2010

Same procedure, same 1,000,000 sample points (WorldClim pixel centres, mapped to the nearest CHELSA pixel), same PCA variant. CHELSA’s period (1981–2010) overlaps the 2000–2012 outcome period, so this is a sensitivity check of the climate source, not a temporally cleaner predictor. Files are read remotely (/vsicurl/, strip by strip, nothing stored): the CHELSA GeoTIFFs are strip-organised, not COGs, so every row is read once (~5.8 GB transfer). Values are converted with the files’ scale/offset; 65535 is treated as NoData. Points north of 84°N (outside CHELSA) or NoData are dropped from both fits.

CHELSA: 998,736 of 1,000,000 sample points valid
component  supp_table1_sd  centre_only_sd  centre_scale_sd  centre_only_cumprop  centre_scale_cumprop  chelsa_sd  chelsa_cumprop
      PC1           780.4           893.2            3.103               0.7913                0.5069      989.3          0.8072
      PC2             362             387            2.069               0.9399                0.7323      391.5          0.9336
      PC3           146.8           184.4            1.393               0.9736                0.8344      217.1          0.9725
      PC4           103.1             131             1.11               0.9906                0.8993      148.9          0.9908
      PC5            59.7           76.16           0.8074               0.9964                0.9336      85.69          0.9968
<xarray.Dataset> Size: 108MB
Dimensions:  (lat: 2640, lon: 2040)
Coordinates:
  * lat      (lat) float64 21kB 17.0 16.99 16.98 16.97 ... -4.979 -4.988 -4.996
  * lon      (lon) float64 16kB -83.0 -82.99 -82.98 ... -66.02 -66.01 -66.0
Data variables:
    cpc1     (lat, lon) float32 22MB ...
    cpc2     (lat, lon) float32 22MB ...
    cpc3     (lat, lon) float32 22MB ...
    cpc4     (lat, lon) float32 22MB ...
    cpc5     (lat, lon) float32 22MB ...
Attributes:
    pca_variant:   centre_only
    source:        CHELSA v2.1 1981-2010 bioclim; sensitivity check
    url_template:  https://os.zhdk.cloud.switch.ch/chelsav2/GLOBAL/climatolog...

2. Soil: OCDENS and PHIHOX, top 30 cm (SoilGrids250m v2017)

Depth-weighted mean over 0–30 cm by the trapezoidal rule on the standard depths 0, 5, 15 and 30 cm (sl1–sl4): (5·(x1+x2)/2 + 10·(x2+x3)/2 + 15·(x3+x4)/2) / 30. Units: OCDENS kg m⁻³; PHIHOX pH × 10.

<xarray.Dataset> Size: 690MB
Dimensions:  (lat: 10560, lon: 8160)
Coordinates:
  * lat      (lat) float64 84kB 17.0 17.0 17.0 16.99 ... -4.994 -4.996 -4.998
  * lon      (lon) float64 65kB -83.0 -83.0 -82.99 -82.99 ... -66.01 -66.0 -66.0
Data variables:
    ocdens   (lat, lon) float32 345MB ...
    phihox   (lat, lon) float32 345MB ...

3. Land cover: ESA CCI 31 → 11 classes, cropland density, distance to urban

The paper simplified the ESA CCI legend to 11 classes without listing them (gap). Our mapping:

<xarray.Dataset> Size: 1GB
Dimensions:                (lat: 7920, lon: 6120)
Coordinates:
  * lat                    (lat) float64 63kB 17.0 17.0 16.99 ... -4.996 -4.999
  * lon                    (lon) float64 49kB -83.0 -83.0 -82.99 ... -66.0 -66.0
Data variables:
    lc_1992                (lat, lon) uint8 48MB ...
    esa_1992               (lat, lon) uint8 48MB ...
    lc_1999                (lat, lon) uint8 48MB ...
    esa_1999               (lat, lon) uint8 48MB ...
    lc_2000                (lat, lon) uint8 48MB ...
    esa_2000               (lat, lon) uint8 48MB ...
    cropland_density_2000  (lat, lon) float32 194MB ...
    dist_urban_2000        (lat, lon) float32 194MB ...
    lc_2015                (lat, lon) uint8 48MB ...
    esa_2015               (lat, lon) uint8 48MB ...
    cropland_density_2015  (lat, lon) float32 194MB ...
    dist_urban_2015        (lat, lon) float32 194MB ...

4. NPP, road density, burned area

NPP raw range: 0.0 65535.0 nodata None
<xarray.Dataset> Size: 22MB
Dimensions:  (lat: 2640, lon: 2040)
Coordinates:
  * lat      (lat) float64 21kB 17.0 16.99 16.98 16.97 ... -4.979 -4.988 -4.996
  * lon      (lon) float64 16kB -83.0 -82.99 -82.98 ... -66.02 -66.01 -66.0
Data variables:
    npp      (lat, lon) float32 22MB ...
<xarray.Dataset> Size: 219kB
Dimensions:       (lat: 264, lon: 204)
Coordinates:
  * lat           (lat) float64 2kB 16.96 16.88 16.79 ... -4.792 -4.875 -4.958
  * lon           (lon) float64 2kB -82.96 -82.88 -82.79 ... -66.12 -66.04
Data variables:
    road_density  (lat, lon) float32 215kB ...

Burned area: GlobFire monthly FinalArea polygons (final perimeter of each fire event; 2001-01 … 2017-12, 204 months) are rasterised (pixel-centre rule) onto a 15 arc-second (~460 m, MODIS-like) grid; the variable is the fraction of the 204 months in which the pixel burned (“monthly average of burned area”, paper Methods).

burned-area source: {'source': 'globfire', 'months': 204, 'globfire_failed': [], 'mcd64a1_file': None}
GlobFire polygon types over all months: {'ActiveArea': 1531488, 'FinalArea': 259995}
<xarray.Dataset> Size: 86MB
Dimensions:      (lat: 5280, lon: 4080)
Coordinates:
  * lat          (lat) float64 42kB 17.0 16.99 16.99 ... -4.99 -4.994 -4.998
  * lon          (lon) float64 33kB -83.0 -82.99 -82.99 ... -66.01 -66.01 -66.0
Data variables:
    burned_frac  (lat, lon) float32 86MB ...

5. Biomes (RESOLVE Ecoregions 2017)

 BIOME_NUM                                               BIOME_NAME  area_in_colombia_mha
       1.0           Tropical & Subtropical Moist Broadleaf Forests             85.389188
       2.0             Tropical & Subtropical Dry Broadleaf Forests              7.851746
       7.0 Tropical & Subtropical Grasslands, Savannas & Shrublands             15.261266
       9.0                            Flooded Grasslands & Savannas              0.000000
      10.0                          Montane Grasslands & Shrublands              1.547240
      13.0                               Deserts & Xeric Shrublands              2.745171
      14.0                                                Mangroves              0.823897

6. Mosaics: Hansen GFC layers and SRTM (VRT)

hansen_treecover2000.vrt BoundingBox(left=-90.0, bottom=-10.0, right=-60.0, top=20.0) (0.00025, 0.00025) ('uint8',)
srtm.vrt BoundingBox(left=-82.00013888888888, bottom=-5.000138888888891, right=-65.9998611111111, top=16.000138888888888) (0.0002777777777777778, 0.0002777777777777778) ('int16',)
<Figure size 1600x500 with 8 Axes>