Earliest Dam Year
First load the network, and attributes
network load_file("data/ohio-river/ohio.network")
network gis_load_attrs("data/ohio-river/nid-uniq.gpkg", "nidId")
node.is_usgs = NAME match "^[0-9]+";
node.is_dam = !is_usgs;
network count(nodes.is_usgs)
network count(nodes.is_dam)
Results:
1806
4181
Counting the upstream dams again,
node<inp>.ndam = int(is_dam) + sum(inputs.ndam);
node.no_dam_us = ndam == 0;
network count(nodes.no_dam_us & nodes.is_usgs)
network count(nodes.no_dam_us & nodes.is_usgs) / count(nodes.is_usgs)
Results:
605
0.33499446290143964
We can see 33% of the USGS gages do not have dams upstream.
And for those that do, let’s look at the construction year,
env.max_year = 9999; # todo test it with nan
node.dam_year = int(get_attr("yearCompleted", env.max_year));
node<inp>.dam_aff_yr = min_num(inputs.dam_aff_yr, dam_year);
node<inp>.dam_affected = dam_aff_yr < env.max_year;
network count(nodes.dam_affected & nodes.is_usgs)
network count(!nodes.no_dam_us & nodes.is_usgs)
network count(nodes.dam_affected & nodes.is_usgs) / count(!nodes.no_dam_us & nodes.is_usgs)
Results:
1152
1201
0.9592006661115737
This shows we have the construction year for 95% of the USGS gages that were constructed after at least one upstream dams.