# Figures, data and scripts of the paper These scripts make every figure of the paper *FlowNest: A Unified Coding System for Position on Global River Networks* (Figures 1–12 and A1–A4) and compute the numbers of Tables 3, 4 and B1 and of the text, from FullNest (the FlowNest release on MERIT Hydro) and the public datasets listed below. Tables 1 and 2 are written by hand: Table 1 compares published datasets and Table 2 lists the columns of the release (its README gives every column). This folder is one full run of `run_all.sh` on 2026-11-20 with `flownest` 1.0.0; it ended without error. The 16 figures it drew are, pixel for pixel, the figures of the manuscript as submitted; here they are `Figures/Figure_01` to `Figure_A4`, and the tables of the manuscript `Tables/Table_01` to `Table_B1`. `Data/` and `input/` are here as folders, and both together in `flownest-figure-data.zip`. ## Folders | Folder | Holds | |---|---| | `scripts/` | `DataNN_*.py` compute (write to `Data/`); `FigNN_*.py` draw (write to `Figures/`); `paths.py` says where every input is | | `input/` | the two tables of river-name classes (see *Numbers that are not computed*); by default also the inputs below | | `Data/` | written by the `Data` scripts and read by the `Fig` scripts | | `Figures/` | the figures of the paper, `Figure_NN.png` and `.pdf`; a run writes its own beside them, `Fig01_…_v1.png` and so on (Figures 4 and A1–A4 also a caption in Markdown) | Most figure scripts write the next free version, `Fig08_…_v1.png`, `_v2.png`, …; `Fig06` and `FigA1toA4` write `_v1` (or `_vK` with `--ver K`), and `FigA1toA4` stops if that file exists. Figures 5–7 go to `Drafts/` unless `--final` is given; `Fig04` and `FigA1toA4` take `--draft DIR` for a png and its caption in another folder. ## Requirements Python 3.9 or later (tested with 3.11), the `flownest` package version 1.0.0 (, `pip install "flownest[crosswalks] @ git+https://github.com/hellolulujiang/flownest@v1.0.0"`), and ``` numpy numba pandas scipy pyarrow rasterio affine geopandas pyogrio shapely>=2.0 matplotlib ``` or `conda env create -f environment.yml`. The figures use the font Arial when it is installed. Tested versions: numpy 2.3.3, numba 0.63.1, pandas 2.2.3, scipy 1.16.1, pyarrow 18.1.0, rasterio 1.4.3, geopandas 1.1.1, pyogrio 0.10.0, shapely 2.1.2, matplotlib 3.10.8. ## Inputs Each input is a folder or file set by an environment variable; the defaults are under `input/` (`input/flownest/` for the release, `input/raw/` for the rest; see `paths.py`). Only the release is needed for most scripts. | Variable | Dataset | Where | Used by | |---|---|---|---| | `FLOWNEST_RELEASE_ROOT` | FullNest, release `20261113_195421`: the four packages `flownest_merit90m_{global, coarser_thresholds, threshold_summary, crosswalks_with_catchments}_20261113_195421`, each in a folder of its name: the files of `global` are on Zenodo one by one (put them in a folder `flownest_merit90m_global_20261113_195421`), the other three are zips to unzip | https://doi.org/10.5281/zenodo.24393217 (global, threshold summary) and https://doi.org/10.5281/zenodo.24393244 (coarser thresholds, crosswalks) | all `Data` scripts except A1–A3; Fig05–Fig07, Fig09–Fig12 | | `MERIT_HYDRO_DIR` | MERIT Hydro v1.0.1, `elv/elv_global_90m.tif` and `upa/upa_global_90m.tif`: the 5° tiles of `elv` and `upa` merged into one GeoTIFF each (3″, 174,000 × 432,000 pixels, 85° N to 60° S; e.g. `gdal_merge.py -co BIGTIFF=YES -co COMPRESS=LZW`) | http://hydro.iis.u-tokyo.ac.jp/~yamadai/MERIT_Hydro/ (registration) | Data14 | | `GRDC_BUREK2023_DIR` | GRDC station locations on MERIT Hydro (Burek & Smilovic, 2022): `evaluation_csv/summary.csv` and `shapefiles_merit/` | https://doi.org/10.5281/zenodo.6906577 (CC BY 4.0) | Data06j, Data22 | | `SWORD_GPKG_DIR` | SWORD v17c, `sword_{AF,AS,EU,NA,OC,SA}_v17c.gpkg` | https://doi.org/10.5281/zenodo.23870877 (CC BY 4.0) | Data22, Fig10, Fig12 | | `NHDPLUS_V2_DIR` | NHDPlus V2, region 17 (`NHDPlusPN/NHDPlus17`) | https://www.epa.gov/waterdata/nhdplus-national-hydrography-dataset-plus | DataA1 | | `NHDPLUS_HR_GPKG` | NHDPlus HR, HU4 1701 GeoPackage | https://www.usgs.gov/national-hydrography/access-national-hydrography-products | DataA1 | | `HYDROSHEDS_DIR` | HydroSHEDS v1: `HydroBASINS_v1c/hybas_na_lev01-12_v1c.zip` and `dir_15s_north-america/hyd_na_dir_15s.tif` | https://www.hydrosheds.org/products | DataA2 | | `HYDRORIVERS_ZIP` | HydroRIVERS v1.0, North America, `HydroRIVERS_v10_na_shp.zip` | https://www.hydrosheds.org/products | DataA2 | | `TDX_HYDRO_DIR` | TDX-Hydro, region 7020014250: `7020014250/TDX_streamnet_7020014250_01.gpkg` | https://earth-info.nga.mil/ (we used the copy on ArcGIS Online, item 365e8b16f1fb438690b11716acd0d459) | DataA3 | No GRDC discharge records are used. ## Run `run_all.sh` runs everything in this order (set the variables first). Every script but four takes less than two minutes on a 10-core laptop (Apple M1 Max, 64 GB). | Step | Scripts | Gives | |---|---|---| | 1 | `Data04`, `Data05`, `Data05c` | the Little Blackfoot and the zoom chain (Figure 5) | | 2 | `Data06c`, `Data06e` (about 10 min), `Data06j` | the GRDC gauges (Figures 5, 8, 9, 12) | | 3 | `Data19`, `Data21` (about 25 min, 3 GB of memory) | release totals; Table 4 and the network numbers of Section 4.3 | | 4 | `DataA4`, then `DataA1`, `DataA2`, `DataA3` | the Clark Fork in FlowNest, NHDPlus, HydroSHEDS and TDX-Hydro (Figures A1–A4, 10, 12) | | 5 | `Data06l`, `Data06m` (about 8 min), `Data06n`, `Data22`, `Data23`, `Data24` | SWORD (Figures 10–12), the gauge–node pairs and their checks (Sections 5.2–5.3, Appendix B), the files of Tables 3 and B1 | | 6 | `Fig01`–`Fig04` | the 10 × 10 test grid (no input) | | 7 | `Fig05`–`Fig07 --final`, `Fig08`–`Fig12`, `FigA1toA4` | the other figures | | 8 | `Data14` (about 20 min with 3 workers) | the one pass over the globe (Section 5.1): running sums from which the area and mean elevation upstream of every channel pixel follow; the area is checked against MERIT Hydro at every channel pixel and the mean elevation is written for the gauges | Each `Data` script writes the numbers it reports to `Data/`: a JSON, or a CSV (`Data06c`, `Data24`) or GeoTIFFs (`Data05c`, `Data06e`) for the figures. Most also check the numbers of the paper with `assert`, so a run that ends without error has reproduced them. ## Numbers that are not computed from the inputs - **River-name classes of the 4,365 gauge–node pairs (Section 5.3).** `Data06n` writes the 4,365 pairs (`paired_10pct` in `Data/Data06n_grdc_gauge_sword_pairs.csv`; 3,241 with the node downstream, 1,757 of them on the same pixel, and 1,124 upstream). Each pair was then read, with the river names in both datasets, the names of the SWORD reaches next to the node, the drainage areas and the next gauge downstream, and given a class and a reason: `input/GRDC_SWORD_4365_name_check_20261120.csv`. The classes give the numbers of Section 5.3: same river 4,071 (S1 3,941, S2 75, S3 26: 4,042; E 29, one of the two names belongs to another stream), different rivers 30 (D), cannot be decided 264 (N0 192 and N+ 50, SWORD gives no name for the reach of the node: 242; U 22): columns `pair_class`, `pair_group` and `pair_reason` (`older_check_class` and `older_check_reason` are those of the older check below, where it covered the pair). Its public copy, with the GRDC names and the areas of the release, is `flownest_merit90m_gauge_node_pair_classes_20261113_195421.zip` in the second FullNest record (24393244). - **The older check of 368 pairs.** `Data23` still counts the classes of an earlier check, of only the 368 pairs whose river names differ (189, 98 and 81 in `Data/Data23_sword_confidence_and_name_classes.json`, from `input/pairs_different_river_names_classified.csv`). The paper no longer reports these numbers; the confidence grades in the same JSON are current. - **Nodes moved by the rules that use SWORD's links (Appendix B: 0.15% of the placed nodes) and the link test without these nodes (98.8%).** These come from a diagnostic table of the program that made the release; that table is not released, so the two numbers cannot be recomputed from the inputs above. ## Third-party code and data - `scripts/_vendor_mmw/mnsi.py` is copied unchanged from WikiWatershed/global-hydrography (commit 5ff54aa, MIT License; see `scripts/_vendor_mmw/LICENSE`). - The two tables in `input/` hold GRDC river names from Burek and Smilovic (2022, CC BY 4.0) and SWORD river names from SWORD v17c (Gearon et al., 2026, CC BY 4.0). - The datasets of *Inputs* are not included; each keeps its own terms. ## License MIT, as the `flownest` package.