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.

02c — Diagnostic 3: a stratified Neotropical training sample

LifeWatch ERIC

Our step-2 model is trained on Colombia only. Diagnostic 3 asks whether training scope (pantropical in the paper vs Colombia here) explains why our model predicts far less regrowth than the authors’ map. This notebook builds a Neotropical training sample with the same definitions as 02b; 03d_transfer_test uses it.

Domain. RESOLVE 2017 biomes 1–3 (tropical and subtropical moist, dry and coniferous forests), latitude −25…25°, longitude −120…−30° (the Americas).

Equal-area stratification. HEALPix depth-5 cells (NESTED, WGS84, about 200 km) are described on a 0.05° lattice: domain area, sub-region and biome. Each cell is assigned to the stratum (sub-region × biome) that covers most of its domain area. Cells with at least MIN_COVER of their area in the domain are eligible. N_CELLS cells are drawn at random: one per stratum first, the rest proportional to stratum area. Sub-regions come from an explicit RESOLVE ecoregion → sub-region table (below).

Labels and pixels (as in 02b, on the 30 m Hansen lattice, pixel-centre rule). Class 1 = domain ∩ Fagan et al. (2022) regrowth polygons; class 0 = domain − forest 2000 − ESA CCI 2000 classes 150–153, 190, 200–202, 210 − all Fagan polygons. Forest = Hansen v1.13 tree cover 2000 ≥ 30 %. Pixels are drawn by Bernoulli sampling with inclusion probability ∝ exact pixel area, with per-cell rates, and then capped at CAP_PER_CLASS points per class and cell, so that regrowth hotspots do not dominate.

Predictors (2000; the Neotropical sample is used for training only). Forest density (1 km-radius disk) and distance to forest (Euclidean, capped at 25 km), computed on 1° tiles with a 0.25° margin exactly as in 02b; SoilGrids v2017 OCDENS / PHIHOX top 30 cm; bioclim PC1–PC4 with the existing PCA loadings (data/clean/bioclim_pca_loadings.csv, not refitted); ESA CCI 2000 land cover in the same 31 → 11 classes; biome.

Disk. Only point values are kept. Hansen tree-cover tiles are downloaded one group at a time and deleted after use (the Colombian tiles in data/raw/hansen are reused and kept); SoilGrids and ESA CCI are read remotely at the points; WorldClim is read from the zip already in data/raw.

Smoke mode (SMOKE=1): three cells (one per sub-region, including the Colombian smoke window), two 1° tiles per cell, cap 150; outputs in data/clean_smoke/ and figures/smoke/.

smoke=False cells=48 cap=1000 workers=12
free disk 22.7 GB; HEALPix depth-5 cell area 41,509 km²

1. Domain and sub-regions (RESOLVE 2017)

Sub-regions from the RESOLVE ecoregion names. Ecoregions that fit none of the six named sub-regions (Chocó–Pacific coast, Caribbean coast of South America, Llanos edge) form a seventh stratum, “Chocó-Pacific and northern lowlands”, so that every domain pixel belongs to a sub-region. The Guiana Shield is grouped with the Amazon. “Cerrado/Chaco edge” holds the dry forests of the South American dry diagonal (Cerrado and Chaco themselves are savanna biomes and outside the domain).

subregion                            BIOME_NUM
Amazon                               1            25
Andes                                1            12
                                     2             4
Atlantic forest                      1            12
                                     2             1
Caribbean                            1             7
                                     2             6
                                     3             3
Cerrado/Chaco edge                   1             1
                                     2             3
Chocó-Pacific and northern lowlands  1             5
                                     2             6
Mesoamerica                          1            19
                                     2            12
                                     3             7

2. HEALPix depth-5 cells on a 0.05° lattice, strata and selection

457 depth-5 cells touch the domain; 313 have cover >= 0.25
                                               n_eligible  domain_mkm2
stratum                                                               
Amazon | biome 1                                      150     5.765054
Cerrado/Chaco edge | biome 2                           34     1.145268
Atlantic forest | biome 1                              27     0.750963
Andes | biome 1                                        21     0.687988
Mesoamerica | biome 1                                  21     0.601044
Cerrado/Chaco edge | biome 1                           11     0.376050
Mesoamerica | biome 3                                  12     0.335076
Mesoamerica | biome 2                                  11     0.292952
Chocó-Pacific and northern lowlands | biome 2           9     0.248031
Chocó-Pacific and northern lowlands | biome 1           5     0.146958
Atlantic forest | biome 2                               3     0.075675
Andes | biome 2                                         2     0.066989
Caribbean | biome 2                                     4     0.064884
Caribbean | biome 1                                     3     0.058971
48 cells selected, 4 touch Colombia
subregion                            biome
Amazon                               1        26
Andes                                1         3
                                     2         1
Atlantic forest                      1         3
                                     2         1
Caribbean                            1         1
                                     2         1
Cerrado/Chaco edge                   1         1
                                     2         5
Chocó-Pacific and northern lowlands  1         1
                                     2         1
Mesoamerica                          1         2
                                     2         1
                                     3         1

3. Fagan et al. (2022) polygons in the selected cells (remote, per layer and bbox)

578340 Fagan polygons; {'regrowth': 387080, 'plantation': 170620, 'open': 20364}

Per-cell Bernoulli rates. The class-1 rate uses the geodesic area of the regrowth polygons whose representative point is in the cell; the class-0 rate uses the cell’s domain area. Rates only set how many candidates are drawn; the cap then fixes the per-cell count.

                                 subregion  biome    cover    rate1    rate0  regrowth_ha
cell                                                                                     
7436                                Amazon      1  0.59627  0.03547  0.00091   6336.86643
7439                                Amazon      1  0.96955  0.03790  0.00056   5983.81344
7446                                Amazon      1  1.00019  0.08565  0.00055   2657.69100
7447                                Amazon      1  1.00054  0.72679  0.00055    314.22065
7451                                Amazon      1  1.00054  0.02212  0.00055  10324.20633
7456                                 Andes      1  0.77843  0.31162  0.00070    721.26576
7468                                Amazon      1  0.99980  0.03283  0.00055   6956.64958
7470                                Amazon      1  0.99895  0.02636  0.00055   8687.19913
7478                                Amazon      1  1.00031  0.17634  0.00055   1304.36664
7479                                Amazon      1  1.00034  0.02715  0.00055   8485.36401
7480                                Amazon      1  0.99690  0.20174  0.00055   1137.93746
7486                                Amazon      1  0.99919  0.40746  0.00056    565.94272
7488                    Cerrado/Chaco edge      1  1.00054  0.08830  0.00055   2586.44625
7492                                Amazon      1  0.99690  0.11501  0.00055   1996.00809
7503                                Amazon      1  1.00057  0.02214  0.00056  10422.62785
7507                                Amazon      1  0.96795  0.15571  0.00057   1481.90588
7518                                Amazon      1  0.98437  0.42422  0.00056    543.57653
7520                                Amazon      1  0.99886  0.05013  0.00056   4595.04788
7526                                Amazon      1  0.99930  0.06458  0.00056   3573.77991
7531                                Amazon      1  1.00057  1.00000  0.00056    192.97643
7547                                Amazon      1  0.99101  0.09883  0.00056   2322.84445
7555                                 Andes      1  0.94537  0.13222  0.00058   1736.24909
7558                                Amazon      1  1.00031  0.06306  0.00055   3647.69935
7559                                Amazon      1  1.00034  0.33589  0.00055    685.80163
7576                                Amazon      1  1.00057  0.38732  0.00056    595.75634
7613   Chocó-Pacific and northern lowlands      1  0.73546  0.09287  0.00075   2466.07726
7615                           Mesoamerica      1  0.38998  0.05562  0.00141   4105.62898
7621                                Amazon      1  1.00105  0.48617  0.00055    473.10059
7622                                Amazon      1  1.00031  0.15921  0.00055   1444.69625
7629                                Amazon      1  0.39463  0.24110  0.00140    949.86698
7650                                 Andes      1  0.99895  0.01272  0.00055  18008.48308
7657   Chocó-Pacific and northern lowlands      2  0.86866  0.00699  0.00063  32557.45041
7957                           Mesoamerica      1  0.26290  0.09861  0.00209   2308.32961
7990                           Mesoamerica      3  0.99254  0.04981  0.00054   4489.05471
8022                             Caribbean      1  0.65099  0.05937  0.00081   3668.64956
8045                             Caribbean      2  0.26228  0.00752  0.00197  28476.66608
8128                           Mesoamerica      2  0.51522  0.00405  0.00101  53293.97464
12094                      Atlantic forest      1  0.73831  0.27868  0.00070    768.71128
12136                      Atlantic forest      1  0.97228  0.35966  0.00054    600.78145
12142                      Atlantic forest      1  0.97997  0.12556  0.00054   1759.48847
12199                   Cerrado/Chaco edge      2  0.58843  0.77714  0.00090    282.35382
12200                                Andes      2  0.69193  0.39456  0.00075    547.64254
12204                   Cerrado/Chaco edge      2  0.31820  0.19934  0.00166   1100.78532
12205                   Cerrado/Chaco edge      2  0.80966  0.12857  0.00066   1718.30613
12230                      Atlantic forest      2  0.90211  0.19480  0.00060   1147.80075
12242                   Cerrado/Chaco edge      2  0.97849  0.08975  0.00056   2516.21065
12251                   Cerrado/Chaco edge      2  1.00054  0.20192  0.00055   1130.97965
12283                               Amazon      1  1.00034  0.00383  0.00055  60076.07496

4. 1° tiles and Hansen tree-cover tiles

Work tiles = 1° tiles holding at least one lattice point of a selected cell’s domain. Each needs the 10° Hansen tiles under its 0.25° margin.

371 work tiles in 21 Hansen groups; 27 Hansen tiles needed: ['00N_040W', '00N_050W', '00N_060W', '00N_070W', '00N_080W', '00N_090W', '10N_050W', '10N_060W', '10N_070W', '10N_080W', '10N_090W', '10S_040W', '10S_050W', '10S_060W', '10S_070W', '10S_080W', '20N_070W', '20N_080W', '20N_090W', '20N_100W', '20S_040W', '20S_050W', '20S_070W', '30N_070W', '30N_080W', '30N_090W', '30N_100W']

5. Per-tile worker (masks, focal predictors and sampling as in 02b)

6. Run tiles group by group (download → process → delete)

group 1/21 00N_050W: 20 tiles (20 new); 89 s; free 20.5 GB
group 2/21 00N_060W: 39 tiles (39 new); 149 s; free 19.4 GB
group 3/21 00N_070W: 51 tiles (51 new); 171 s; free 19.4 GB
group 4/21 00N_080W: 46 tiles (46 new); 198 s; free 19.2 GB
group 5/21 00N_090W: 2 tiles (2 new); 203 s; free 19.2 GB
group 6/21 10N_060W: 19 tiles (19 new); 213 s; free 19.3 GB
group 7/21 10N_070W: 37 tiles (37 new); 231 s; free 19.5 GB
group 8/21 10N_080W: 22 tiles (22 new); 246 s; free 19.4 GB
group 9/21 10N_090W: 2 tiles (2 new); 251 s; free 19.5 GB
group 10/21 10S_040W: 4 tiles (4 new); 262 s; free 19.4 GB
group 11/21 10S_050W: 28 tiles (28 new); 289 s; free 20.0 GB
group 12/21 10S_060W: 7 tiles (7 new); 294 s; free 20.0 GB
group 13/21 10S_070W: 28 tiles (28 new); 321 s; free 20.6 GB
group 14/21 10S_080W: 9 tiles (9 new); 331 s; free 20.7 GB
group 15/21 20N_080W: 10 tiles (10 new); 347 s; free 20.7 GB
group 16/21 20N_090W: 10 tiles (10 new); 387 s; free 20.0 GB
group 17/21 20N_100W: 1 tiles (1 new); 392 s; free 20.0 GB
group 18/21 20S_050W: 16 tiles (16 new); 406 s; free 21.2 GB
group 19/21 20S_070W: 7 tiles (7 new); 411 s; free 22.0 GB
group 20/21 30N_090W: 11 tiles (11 new); 418 s; free 22.0 GB
group 21/21 30N_100W: 2 tiles (2 new); 423 s; free 22.7 GB
437830 candidates; {0: 304067, 1: 133763}

7. Land cover 2000 at the points (ESA CCI v2.0.7, remote, per cell) and class-0 exclusions

class-0 candidates dropped for ESA CCI 2000 classes [150, 151, 152, 153, 190, 200, 201, 202, 210]: 24,208 of 304,067
106265 points after pre-cap

8. Bioclim PC1–PC4 (existing PCA loadings applied to WorldClim v2.1 at the points)

WorldClim read in 14 s
bioclim PCs: NaN share 0.0001

9. Soil: SoilGrids v2017 OCDENS and PHIHOX, 0–30 cm (remote, rows holding points)

The files are strip-organised (one row per block), so each of the 8 layers is read in 512-row chunks restricted to the rows that hold points, in parallel threads (GDAL releases the GIL; forked processes can deadlock on GDAL’s curl state). Depth weighting as in 02: (5·(x1+x2)/2 + 10·(x2+x3)/2 + 15·(x3+x4)/2) / 30.

soil read in 511 s

10. Consistency with the Colombian layers of 02

Points inside the Colombian window must get the same values as 02b would give them from data/clean/*.nc (same sources, nearest neighbour). Small differences can arise only at pixel boundaries.

variable     n  share_equal  max_abs_diff
     pc1 21615          1.0           0.0
     pc2 21615          1.0           0.0
     pc3 21615          1.0           0.0
     pc4 21615          1.0           0.0
  ocdens 20813          1.0           0.0
  phihox 20813          1.0           0.0
 lc_2000 21639          1.0           0.0

11. Final cap, balance, split, save

dropped 2,497 points with a missing predictor
after cap: class 1 48,000, class 0 34,700; balanced 34,700 per class
set         label
train_pool  0        26025
            1        26025
validation  0         8675
            1         8675
label                                    0      1
subregion                                        
Amazon                               13391  18827
Andes                                 4000   2914
Atlantic forest                       4000   2895
Caribbean                             2000   1432
Cerrado/Chaco edge                    5309   4338
Chocó-Pacific and northern lowlands   2000   1423
Mesoamerica                           4000   2871
Colombian points: {(False, 0): 31698, (False, 1): 32520, (True, 0): 3002, (True, 1): 2180}
                                 subregion  biome     cover  n_class0  n_class1
cell5                                                                          
7436                                Amazon      1  0.596270      1000       717
7439                                Amazon      1  0.969548      1000       719
7446                                Amazon      1  1.000186       504       733
7447                                Amazon      1  1.000539       134       706
7451                                Amazon      1  1.000539      1000       710
7456                                 Andes      1  0.778425      1000       715
7468                                Amazon      1  0.999804       406       725
7470                                Amazon      1  0.998952       237       734
7478                                Amazon      1  1.000314       131       733
7479                                Amazon      1  1.000338       278       719
7480                                Amazon      1  0.996905       168       716
7486                                Amazon      1  0.999186       142       709
7488                    Cerrado/Chaco edge      1  1.000536       703       727
7492                                Amazon      1  0.996905       218       736
7503                                Amazon      1  1.000567      1000       696
7507                                Amazon      1  0.967955       903       734
7518                                Amazon      1  0.984372       425       714
7520                                Amazon      1  0.998859       621       716
7526                                Amazon      1  0.999298       836       734
7531                                Amazon      1  1.000567        37       724
7547                                Amazon      1  0.991013       668       728
7555                                 Andes      1  0.945365      1000       715
7558                                Amazon      1  1.000314       281       729
7559                                Amazon      1  1.000338       101       724
7576                                Amazon      1  1.000567       145       766
7613   Chocó-Pacific and northern lowlands      1  0.735462      1000       698
7615                           Mesoamerica      1  0.389979      1000       713
7621                                Amazon      1  1.001054       156       729
7622                                Amazon      1  1.000314      1000       734
7629                                Amazon      1  0.394628      1000       721
7650                                 Andes      1  0.998952      1000       733
7657   Chocó-Pacific and northern lowlands      2  0.868660      1000       725
7957                           Mesoamerica      1  0.262901      1000       723
7990                           Mesoamerica      3  0.992540      1000       719
8022                             Caribbean      1  0.650988      1000       704
8045                             Caribbean      2  0.262280      1000       728
8128                           Mesoamerica      2  0.515216      1000       716
12094                      Atlantic forest      1  0.738309      1000       717
12136                      Atlantic forest      1  0.972277      1000       737
12142                      Atlantic forest      1  0.979968      1000       701
12199                   Cerrado/Chaco edge      2  0.588433       606       721
12200                                Andes      2  0.691928      1000       751
12204                   Cerrado/Chaco edge      2  0.318200      1000       735
12205                   Cerrado/Chaco edge      2  0.809655      1000       730
12230                      Atlantic forest      2  0.902114      1000       740
12242                   Cerrado/Chaco edge      2  0.978488      1000       710
12251                   Cerrado/Chaco edge      2  1.000539      1000       715
12283                               Amazon      1  1.000338      1000       721

12. Map of the selected training cells (HEALPix depth 5, WGS84)

<Figure size 900x700 with 1 Axes>