Giter VIP home page Giter VIP logo

riverscapes-tools's Introduction

Open GIS

This is a monorepo housing all of the python open-gis tools.

./lib and ./packages

Both ./lib and ./packages contain pep8-compliant python packages.

  • ./lib is for anything that can be shared between tools
  • ./packages is for the tools themselves. They cannot depend on one another.

If you find that your tools have code they need to share you can either pull it into the ./lib/commons package or, if there's enough code, create a new ./lib/whatever package.

Repo guidelines:

We're pretty much using the Gitflow Workflow

  1. All work MUST happen on branches.
  2. Make sure your pull requests merge onto dev and not master.
  3. Hotfixes may be applied directly to master... carefully and after lots of testing.
  4. Add your issue and/or pull request to a milestone to make sure it will be included.
  5. Attach your commits to issues and pull requests by referencing them in commit messages

Python Environment

Philip Bailey - 12 Jul 2023

The recommended Python setup involves a single .venv in created in the repo root folder. This venv is shared among all the packages (RSContext, VBET etc).

Each package has its own workspace. And these "package workspaces" do not include the root folder that contains the .venv. Therefore, when working in a package workspace Visual Studio Code can't find the root .venv.

We overcome this (on OSX) by creating a sym link to the root .venv inside each package workspace using the following command.

ln -s ../../.venv .

Then inside the package workspace you can do the following to point the workspace at this sym link (which links back to the one and only root .venv):

  1. Open any package workspace (RSContext, VBET etc)
  2. Open any Python code file.
  3. click on the Python version in the status bar at the bottom right of Visual Studio Code. This will prompt to select a new interpreter.
  4. Click "Set At Workspace Level...".
  5. Visual Studio Code "should list" the sym link .venv folder as one of the options. If it doesn't then you can browse to it.

This workflow needs to be repeated for each riverscapes tools package.

Working inside Github codespaces

If you are working inside a Github codespace there is no need for any kind of bootstrapping or .venv or even .env files.

Data and files

The data dir cor codespaces is set to /workspaces/data. This folder is shared between all users of this codespace.

You can open a window to the data by typing code /workspaces/data/.

From there files can be dragged into the vscode window to upload them to the codespace. To download files or folders right click on them and select "Download".

You may wish to use projects downloaded from the Riverscapes Warehouse. This codespace comes complete with rscli installed.

To download projects you must know: The project id from the warehouse, the HUC and the project type.

rscli download --id XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX /workspaces/data/rs_context/17060304

A browser window should pop open to allow you to authenticate your Riverscapes Warehouse account. Once authenticated the project will be downloaded to the data folder.

Make sure you use the folder name that matches what this tool expects for the project type and huc number.

riverscapes-tools's People

Contributors

dependabot[bot] avatar joewheaton avatar jtgilbert avatar kellymwhitehead avatar mattreimer avatar philipbaileynar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

riverscapes-tools's Issues

Two hydro 17 BRAT runs

@tyler1218hatch these are the two BRAT runs that you requested so that you can get insight into the hydrology and vegetation.

I would really like to discuss your findings when you dig into these runs. Part of my motivation is to understand what information you are using to review the quality of the run and make sure that a) you know how to quickly get at the information that you need, b) add any additional queries/reports to help speed up your review.

Review Layer Files for Fields that can now be -1

We recently implemented the change that numeric fields in the BRAT output ShapeFile now store -1 where the SQLite database has zero. This was flagged up when we noticed HUCs with no railways defaulting the iPC_Rail field to zero when there are no railways within the HUC (#56).

Please review each layer file for BRAT make sure that -1 values appear in a sensible way. For some fields it might make sense that features with -1 just don't show up. But for layers like railways (iPC_Rail) it might make sense to display these features as "far away from railways". The features should show up, just using the lowing risk level symbology.

Please make sure you review all BRAT layer files and now just iPC_Rail.

Note that this does not affect string fields in the BRAT output ShapeFile. ShapeFiles store an empty string where there's no value in the SQLite database. We do not store -1 in string columns if there's no value in the database.

Valley Bottom Segmentation Tool

To get useful metrics and measures out of VBET (and dashboard summaries), we need the valley bottom to be something other than a liklihood raster (#5) or a single polygon blob (#6). I am going to call this Valley Bottom Segmentation. It is reasonably illustrated below (from these slides):
image

A valley bottom segment could be defined as a longitudinal portion (reach or segment) of a riverscape, which spans the entire valley bottom width. They will typically be longer (longitudinally) than it is laterally (cross-valley).

Ways to get them

In a commercial-grade or professional-grade version of VBET, we might let the user choose which way to get there, or let them choose the valley bottom segmentation method and produce multiple valley bottom segmentation realizations. These include (not mutually-exclusive... could be combined or used to further split/segment):

  • Load an already segmented network, segments drawn perpendicularity from all reach segment end points into VB intersection.
  • Segment based on tributary (of intput VBET network) junctions - Note: this would be really important that the end of the tributary includes the fan of that tributary.
  • Further segment based on intersection with polygon input (e.g. of land ownership or property boundaries) - pyBRAT has this option
  • Further segment based on intersection of polyline input with drainage network (e.g. road crossings) - Note: it is important not to allow this for polyline intersection of VBET polygon, because many roads run parallel.
  • Further segment based on a uniform segmentation length (e.g. RCAT uses 500 m and BRAT uses 300 m by default).
  • Further segment based on variable segmentation length defined by continuous network function (this is what Fluvial Coridor Toolbox can do and GNAT implemented as well).

Why the above are important

The valley bottom segment is important as it defines the length-scale over-which potential valley bottom derivatives and metrics can be summarized.

@philipbaileynar - this is one way we give users ownership of their own VBETs.

VBET Attributes

Once a valley bottom is segmented (see Riverscapes/vbet#7), or a riverscape network is produced from that segmented valley bottom (see Riverscapes/vbet#8), it is possible to generate a variety of simple metrics (i.e. fields in attribute table), stacked profile or longitudinal plots of these (e.g. see https://riverscapes.github.io/NetworkProfiler/), or horizontal bar plots by reach.
Useful analyses in VBET would include:

  • Integrated Valley Bottom Width (Valley Bottom segment area divided by VBET Network CL length)
  • Valley CenterLine Length
  • Change in VB Width from Upstream
  • Change in VB Width to Downstream
  • Proportion Active Channel (i.e. Proportion of Valley Bottom in your Channel class
  • Proportion Active Floodplain (if mapped)
  • Proportion of the threshold classes (e.g. 50%, 60%, 70%, 80%, 90%)
    I describe what we'll be doing with these here. In short, we need to map valley bottoms and then break them into active and non-functional components:
    image

Even the current version is getting us close to some of these things:
image

Interactive part of VBET

What we do

The primary output of a cloud-generated or model run of VBET could logically be the Likelihood of being Valley Bottom Raster (see #13 ). This will be some 0 to 100% symbology shown transparently over the underlying hillshade. However, the most useful output (and one people are expecting) is just a valley bottom polygon. It is that polygon that is an input into BRAT, RCAT, LTPBR Planning, Confinement, etc.

Proposal

I want to turn the concept of a valley bottom polygon in VBET as something that is a user-owned experience in same way GCD analyses are owned by a user). Yes GCD could produce automatically a bunch of likely thresholded DoDs, but the user has to choose thresholding method. So, I propose we:

  1. relegate the Likelihood of being Valley Bottom Raster to an "Intermediate" as well as evenly incremented polygon outputs of that (e.g. 50%, 60%, 70%, etc).
  2. VBET projects start having outputs or analyses when the user chooses a liklihood value and then that becomes a valley bottom polygon (two standard forms of symbolizing - Hollow with dashed yellow lines, and transparent green)
  3. A VBET analysis is either just an unedited thresholded (as in 2), or edited based off a threshold. This is going to be really common where we have someone take the initial polygon, and then they tweak it for their own purposes.

Where are the Normalized Evidence inputs from Steps 1-3?

If ever there was a good example of an intermediate, it would be the transformation of the following in Steps 1- 3 from inputs to evidence:
Step 1 - Slope Evidence Raster
Step 2 - HAND Evidence
Step 3 - Channel Evidence - We should see this (in addition to the NHD Flow Areas and new Bankfull Polygon Riverscapes/vbet#3).

Please write these normalized lines of evidence (nLoE) to Project intermediates\ folder as:

  • nLoE_Slope.tif
  • nLoE_HAND.tif
  • nLOE_Channels.tif

What network are you using as an input?

One of the most fundamental inputs into VBET is the drainage network. Its extent controls:

  • Where classic VBET (slope analysis within buffer from stream) looks
  • Where new VBET waterbodies works (not just polygons, but bankfull buffer polygon)
    The only part that doesn't get included is the version you run now is HAND, but when we run HAND with our own inputs (e.g. NED and NHD), we need the D (i.e. drainage) specified as input.

There are some things to work out:

  1. Which drainage are you using by default (I think it is NHD + HR)?
  2. What extent of the drainage network (i.e. are you filtering by an FCODE of 46006 for perrenial?

I want 46003 (intermittent) and 46007 (intermittent) and you end up needing a lot of Artificial Path's too to get right network - @wally-mac will have insights on this).

Also, that critical input is not part of current business logic. @joewheaton will fix.

oPBRC_UI and oPBRC_CR: Fields should be fixed

Documentation here shows that the field oPBRC_UI should hold data about risk, with the categories (Negligible, Minor, Some, Considerable). And oPBRC_CR should hold data about restoration opportunties (Easiest, Straight Forward, Strategic). However, this attribute table shows that they are switched in sqlBRAT. They need to be switched back.

image

Also, the only values for oPBRC_CR (Currently shown as oPBRC_UI) that appeared in the most recent outputs are NA and Easiest - Low-Hanging Fruit. The values "Straight Forward - Quick Return" and "Strategic - Long-Term Investment" don't appear. We need to check if this is actually an error and the conditions need to be updated, or if those watersheds just happened to not have those categories. Attached is an image of the outputs.
image
image

The best place to use as reference is the old Constraints & Opportunities script.

Report - Dam Capacity v Observations

Missing from the BRAT capacity report section. These all need the observation data to work:

  • Number of dams snapped -The total number of actual dams snapped to the network. 676
  • Total Dam Count - The total number of actual dams. 676
  • % Dams snapped to the network - The percent of actual dams snapped to the network. 676
  • % of reaches within capacity estimate The proportion of reaches where the actual number of dams did not exceed our capacity estimate 717
  • X out of Y reaches above the capacity estimate were less than 150m - Of all the reaches that were above the capacity estimate, how many of them were really short reaches? 717

CRB Hydrologic Equation Errors

@tyler1218hatch we have improved the process of exporting the BRAT parameters from the postgres database to include verification of the hydrologic equations. This should identify problems before we attempt to run BRAT.

Below are the current errors associated with equations in the database. I worked hard to make the format helpful to you. You can see the equation that caused an error, together with the Python exception message and then all the watersheds that experienced this problem.

It looks like this first round of errors is due to minimum elevation being zero, which throws an exception when attempting to raise this elevation to a negative power.

Please update either the parameters or the equations in the database to fix this issue. Consult with @wally-mac should you need guidance on how best to resolve these issues.

Hydrologic equation Error

Equation: 1.24509*(10**-5.9071)*(DRNAREA**1.0360)*(PRECIP**1.0789)*(MINELEV**-0.2122)*(SOILCAPACITY**-3.5615)
Exception: ZeroDivisionError('0.0 cannot be raised to a negative power')
Watersheds:
        17100207:
                ELEV: 58.723606
                FOREST: 14.923506
                PRECIP: 1870.9722
                MINELEV: 0.0
                MEANSLOPE: 2.1254585
                CANOPY_PCT: 54.347507
                SOILPERM: 2.6200001
                JANMAXT2K: 8.16
                I24H2Y: 411625.9
                ELEV1K: 58.723606
                FORESTP1: 15.923506
                JANMINT2K: 6.11
                SOILCAPACITY: 244.6662
                MINANTEMP: 44.76879
                MAXELEV: 394.0
                DRNAREA: 1.0
        17100303:
                ELEV: 280.86893
                FOREST: 32.85645
                PRECIP: 1494.3339
                MINELEV: 0.0
                MEANSLOPE: 5.7750564
                CANOPY_PCT: 58.421772
                SOILPERM: 1.7642801
                JANMAXT2K: 8.17
                I24H2Y: 410889.0
                ELEV1K: 280.86893
                FORESTP1: 33.85645
                JANMINT2K: 2.49
                SOILCAPACITY: 176.61343
                MINANTEMP: 42.563198
                MAXELEV: 1236.0
                DRNAREA: 1.0
        17100304:
                ELEV: 211.69147
                FOREST: 23.695194
                PRECIP: 1705.4775
                MINELEV: 0.0
                MEANSLOPE: 4.2562046
                CANOPY_PCT: 57.53793
                SOILPERM: 2.4027274
                JANMAXT2K: 8.77
                I24H2Y: 449279.22
                ELEV1K: 211.69147
                FORESTP1: 24.695194
                JANMINT2K: 4.6
                SOILCAPACITY: 195.16591
                MINANTEMP: 44.11308
                MAXELEV: 869.0
                DRNAREA: 1.0
        17100306:
                ELEV: 201.66078
                FOREST: 21.562847
                PRECIP: 2382.3193
                MINELEV: 0.0
                MEANSLOPE: 5.2835402
                CANOPY_PCT: 57.43847
                SOILPERM: 1.6346914
                JANMAXT2K: 9.51
                I24H2Y: 531826.8
                ELEV1K: 201.66078
                FORESTP1: 22.562847
                JANMINT2K: 4.1
                SOILCAPACITY: 159.47954
                MINANTEMP: 45.486057
                MAXELEV: 1137.0
                DRNAREA: 1.0
        17100312:
                ELEV: 413.61993
                FOREST: 35.258606
                PRECIP: 2586.85
                MINELEV: 0.0
                MEANSLOPE: 8.664532
                CANOPY_PCT: 60.47483
                SOILPERM: 1.2205608
                JANMAXT2K: 9.68
                I24H2Y: 550896.25
                ELEV1K: 413.61993
                FORESTP1: 36.258606
                JANMINT2K: 2.84
                SOILCAPACITY: 141.20355
                MINANTEMP: 44.20969
                MAXELEV: 1359.0
                DRNAREA: 1.0

User Add Additional Lines of Valley Bottom Evidence

Request

Is it possible to queue up and accept additional lines of valley bottom evidence. Examples that come to mind are:

  • FEMA Flood Maps, which can include the:

    • "Floodway" as an additional line of evidence for active channel
    • "1% Annual Chance Flood Hazard" - Will include "active floodplain" but also a lot of stuff that does not regularly flood (i.e. flooding more than every 5 - 10 years)
    • "0.2% Annual Chancel Flood Hazard" - *Also not a bad proxy for "non-functional"
    • "Area with Reduced Risk due to Levee" - this should be "non-functional"
      image
  • User uploaded polygon their call...-

  • Quaternary Geology map (anything mapped as Qa (Quaternary Alluvium) or a specific alluvial surface (not terraces) is pretty good:
    image

  • Wetland Maps (e.g. NWI - Wetlands within valley bottom areas are a pretty good indication of "active floodplain" and a good line of evidence of being active valley bottom.
    image

  • Fluvial Hazard Zone Maps - There are an increasing number of channel migration zone, freedom space and fluvial hazard zones that are helpful where they exist:
    image

Feature

Initially a command line utility, to be able to add to riverscapes project additional lines of evidence, and have arguments for their weight and populating metadata tags (what, who, when).

Help me understand HAND normaliztion?

I get that the purpose of normalizing the HAND input into 0 - 1 is to make it easier to combine multiple lines of evidence.

The goal is to invert the raster so that high HAND values have the lowest raster values and then discard and values greater than 50 m.

I also get that we can display that intermediate like below (#16):

image

However, I am confused on why you did exactly this:

It is divided by -50 and then 1 added to the result. (code). Again the constant value of 50 is passed as an argument.

  1. Why 50? I get the negative (to invert it). Is 50 meters an arbitrary or informed cut-off? It seems like this should be a function of drainage area.
  2. Is it something that requires user judgement? Calibration?
  3. Is exposing that knob significant? Here you hint 50 is an argument.

File collision handling for multi-process shared file system

This is a cybercastor-related issue that both the downloader and zipper can collide with file writing. Usually this isn't a huge deal but when we run massively parallel jobs with 100+ of the same tool running simultaneously we're bound to find some processes competing for write permissions on the same files.

Strategies:

  1. put down a .pending file that the other processes will wait for (a reasonable amount of time) before overwriting.
  2. The scratch space for RS_Context (where we unzip things) needs to be common only to that process and cleaned up properly afterwards.
  3. Delete any corrupt files that can't be unzipped.

GNAT package

We are about to embark on writing several tools for calculating reach attributes. The legacy ArcPy versions were stored here. We then started a pyGNAT repo.

The open source code will rely heavily on rscommons. Therefore I think that the new code should live in this riverscapes-tools repo.

Please stub out a new package in this repo for gnat. For now this will contain a loose assortment of scripts that each calculate one or more geomorphic attributes. The new package should have:

  • dummy script showing how to reference rscommons. confiment.py is one of the first tools, so probably start with this one.
  • Visual Studio code workspace.
  • launch.json

BRAT Validation Issues

Based on a call we had with @mhallerud and @wally-mac

Possible unit problems in the equations

DRNAREA=sqMiles
ELEV=ft (5693)
FOREST=% (17.31)
PRECIP=in (21.77)

QLow
0.0247 * ((DRNAREA/0.3861021585424458)**1.05) * ((ELEV/3.28084)**-3.86) * (FOREST**-0.947) * ((PRECIP/0.0393701)**3.99)

Q2
0.00557 * ((DRNAREA/0.3861021585424458)**0.754) * ((PRECIP/0.0393701)**2.34)

here's an excerpt from the DB

PRECIP	PRECIP,PRECPRIS10	536.4481810897436
ELEV	ELEV	1735.325498590117
MINELEV	MINELEV,MINBELEV	1334.19677734375
RR	RR	1707.66357421875
FOREST	FOREST	11.979218556596658
SLOP30_30M	SLOP30_30M	4.073632316368693
MEANSLOPE	MEANSLOPE	10.095673577064435

Here's the code that drives this:
https://github.com/Riverscapes/sqlBRAT/blob/master/hydrology.py#L91-L96

Maggie sent some reference images.

Screen Shot 2020-05-21 at 1 25 03 PM

Screen Shot 2020-05-21 at 1 25 23 PM

Screen Shot 2020-05-21 at 1 25 41 PM

Screen Shot 2020-05-21 at 1 25 59 PM

iPC_RailVB Values are 0 when they should be NULL

In a watershed without Railroads in the valley bottom like North Fork John Day, all streams are given an iPC_RailVB value of 0. This is then symbolized and interpreted as every stream being right next to a railroad in the valley bottom. This could be fixed by assigning those streams NULL or negative values to distinguish them.

image
image

Observations And Electivity Metrics

I have started to incorporate USUs observation dataset into the National Project and then feeding it into BRAT Build so that each BRAT project contains just the subset for the particular HUC8.

This work needs to be finished and then the data used in an updated version of the pyBRAT 3 electivity metrics. This code can be simplified greatly now that we have the SQLite database.

Include Mean Annual Precipitation from NHDPlusID

The NHDPlusHR dataset includes the mean annual precipitation for each reach. This value is stored in the NHDPlusIncrPrecipitationMA table. The values are stored in the PrecipMA column. This table also has the NHDPlusID for associating the values back to the reach geometries.

Having the mean annual precipitation for each reach would improve our bankfull width calculations (#12) that currently use a constant precipitation value for the entire watershed. Watersheds with high relief have spatially variable precipitation as evidenced by the PRISM rasters that we are including in the riverscapes context projects.

The goal of this task is to import the mean annual precipitation value into the riverscapes context projects so these data can be used by our other tools.

I will point out that we keep adding requests for more and more aspects of the NHDPlusHR data! Each request requires us to refactor the code and then re-run every project! Surely (@MattReimer) its about time that we simply convert the NHDPlusHR dataset into a GeoPackage and include the entire thing in the riverscapes context project. It's up front work, but it will avoid future requests like this one. Note I've prototyped some code to do this.

Report - Dam Size

Existing/Historic Dam Complex Size 1035

Table that bins segments and their lengths by existing/historic dam complex size

Screen Shot 2020-06-11 at 2 40 50 PM

@tyler1218hatch I get most of the existing pyBRAT report calculations, but this one flummoxes me. I think a quick explanation would help.

[Windows] .env file loading and `safe_makedirs` method doesn't work on windows

We need to normalize how windows paths are stored in .env files, how they're read by the settings.py file and then how they work inside safe_makedirs

Whatever changes you make should make sure that linux paths are also accepted /soemthing/somethingelse/blah/blah/blah

The first problem is in the way we load our .env files:

https://github.com/Riverscapes/riverscapes-tools/blob/master/lib/commons/rscommons/dotenv.py#L51-L64

There may be other problems hiding behind this first one but we won't know until we fix this.

Riverscapes Context Metadata

There is literally zero metadata for any of the layers in the Riverscapes Context project file. Each layer should have a metadata sub element with information describing where the data were obtained etc. (Note that RAVE has a feature request for displaying this information).

Most of the data that we import into the project come with some form of metadata. This is certainly true of the NHD, NED and NTD downloads. So this task is simply to repurpose this existing information and inject it into the riverscapes project file.

There are several strategies for storing metadata with our national project datasets and then incorporating it into the riverscapes context project. We could use side car files, or better still store that information in the national project file and use it from there.

@joewheaton is forbidden from commenting on this issue ;-)

Can you walk through new VBET algorithm?

I understand that the new VBET is using multiple lines of evidence and that is currently:

  • old VBET (i.e. low slopes in buffer near drainage network)
  • waterbodies (see #12)
  • HAND

What I want to know is:

  1. What are exact current sources and methods for each line of evidence?
  2. How are different lines of evidence normalized (e.g. to a probability or membership into valley bottom class)?
  3. Are the normalized lines of evidence, something for which an intermediate layer and symbology can or should be produced? For example, HAND might go from actual height above nearest drainage (units of meters) to a likelihood of flooding, which could be symbolized categorically in something like (not suggesting these yet, just illustrating)
  • Definitely Floods
  • Probably Floods
  • Might Flood Occasionally
  • Could Plausibly Flood
  • Not Likely to Flood
  • Implausible to Flood
  1. How are different normalized lines of evidence combined to get a "probability" or "likelihood" score of being a valley bottom cell?

Report - Density Calculations

Table that bins certain hydrologic attribute values into three bins, then shows the mean dam density for each of those bins. This could possibly become a bar graph. 953

  • Low Flow
  • High Flow
  • Stream Slope
  • Stream Power Low
  • Stream Power High

Screen Shot 2020-06-11 at 10 47 09 AM

@tyler1218hatch are the bins for discharge, slope and stream power hard coded? Or are they determined from the data?

Help me understand what Slope Evidence is

I get that the purpose of normalizing the slope input into 0 - 1 is to make it easier to combine multiple lines of evidence.

The goal is to invert the raster so that low slope values have the highest raster values and then discard (set null) any areas that had an original slope value of 12 degrees or greater.

I also get that we can display that intermediate like below (#16):

image

However, I am confused on why you did exactly this:

The first step is to divide the original slope raster by -12 and then add 1. We then set any negative values to NULL. (code). The constant value of 12 is passed to the script as an argument so that it can be adjusted easily.

  1. Why 12? I get the negative (to invert it). Is 12 degrees an arbitrary or informed cut-off?
  2. Is it something that requires user judgement? Calibration?
  3. Is exposing that knob significant?
  4. I take it this only works when the range is well defined (i.e. works for degrees slope upto 90 but not for percent slope)?

Master List of Reach Attributes - GNAT and River Styler

Please provide the master list of stream attributes that pyGNAT needs to calculate. The usual suspects are:

  • Sinuosity (valley or reach?)
  • Gradient (valley or reach?)
  • Stream Order (any particular method?)
  • Braidedness?

Obviously it would be nice to have the the master tree of reach types and the criteria for how each attribute applies to each type.... but for now we just need the master list of all attributes that will occur in the reach typing logic.

Update National LandFire Rasters

Thanks to @tyler1218hatch we now have national LandFire 2.0.0 rasters! This is a hug step forward! Hopefully we don't have to revisit this topic again for a very long time.

@MattReimer can you please incorporate these rasters into the national project and ensure that they are wired up for the next batch of tool runs.

I have put them on s3 in nardata/temp please delete them from this location when you are done.

The rasters might require some cleaning:

  • -9999 should be reclassified as NoData.
  • LZW compression doesn't feel quite right. I think we use no-deflate on integer rasters right?

Please also pay specifical attention to the XML lookup files that Tyler prodived with the raster. Maybe we can use these directly in place of the ones we generated?

Riverscape Network Generator Tool

Once a valley bottom is defined (#6 ) and (optionally) segmented (see Riverscapes/vbet#7), a Riverscape Network can be defined (different than the input from the hydrographic or drainage network to the tool). The network will be the valley bottom centerline.

If derived from a regular #14 valley bottom polygon, it is just segmented at tributary junctions. If derived from a segmented valley bottom polygon Riverscapes/vbet#7, the network is segmented at those intersections.

Current vs. Future Request

The current request would be for this as a command line utility. The later request would be as tools in the commercial grade web-app or in a professional grade GIS tool.

Calculate MODIS LST for hydro region 17

The goal of this task is to produce a SQLite database containing land surface temperature (LST) for NHDPlus HR reaches in hydro region 17. For now, this is a one-off request. This process will not get integrated into any of our production tools.

LST data are available in a custom (NOAA?) HDF4 format. You can drag these into QGIS and they seem to appear OK!

Screen Shot 2020-07-28 at 3 25 49 PM

The goal is to extract the average value from these rasters for each reach for all MODIS data between 2005 and 2015. We will do this by an area weighted average of the raster cells within the reach catchment polygons (shown in green below):

Screen Shot 2020-09-10 at 9 21 45 AM

We want to avoid reprojecting the raster values (because this will resample and alter the raw values). So instead of reprojecting the MODIS rasters we will reproject the catchment polygons to the custom MODIS coordinate reference system. You can see this by right clicking on the MODIS raster in QGIS and viewing the layer properties.

Note that the MODIS rasters contain several bands, each representing a different data product. The product that we want is the MODIS 8-d daylight pass LST. This is one of the options when you drag the HDF file into the QGIS map window. It also shows you which band number that represents (note that GDAL bands are 1-based referenced. Not zero based.)

Note that the data source string gives a hint as to how to load one of these HDF files using GDAL driver in Python.

Screen Shot 2020-09-10 at 11 31 34 AM

Screen Shot 2020-09-10 at 11 29 54 AM

Deliverable

The deliverable should be a simple SQLite database with the following columns:

  • NHDPlusID (integer, identifies the reach)
  • MODIS_Scene (DATETIME, identifies the MODIS scene for which the LST value applies)
  • LST (REAL, mean MODIS 8-d LST value)

Here's some DDL that creates this table in SQLite:

CREATE TABLE MODIS_LST (
    NHDPlusID   INTEGER  NOT NULL,
    MODIS_Scene DATETIME NOT NULL,
    LST         REAL,
    PRIMARY KEY (
        NHDPlusID,
        MODIS_Scene
    )
)
WITHOUT ROWID;

NHD Data

I see three options for working with the NHD data. My current preference is for #3. Ping me and we can discuss.

  1. We run riverscapes context for every 8 digit HUC in hydro region 17. We need to do this anyway for VBET and BRAT.
  2. We take our code for downloading NHD data and write a new script to just run this method. It will be faster than running riverscapes context for every HUC.
  3. We have developed new code for uploading NHD data to PostGIS. This might be the simplest method because then the LST script can simply connect to PostGIS and loop over all the reaches there.

Note that NHD stores the reach identification NHDPlusID as a float, but the output SQLite database should store it as an integer. I've found it reliable to simply convert the value in Python.

MODIS LST Data

We need all MODIS data from 2005 to 2015.

These data are available via an FTP site, but I think you need login credentials to download more than a single item. After some poking around I think the best way to obtain the MODIS data is via the desktop software utility called DAAC2Disk. This seems to handle the login process and then allows you to enter search parameters for filtering to specific datasets.

MODIS raster cell resolution is roughly 900m. Many of the reach catchments will fall inside a single pixel. However, when there are multiple pixels that intersect a MODIS pixel we probably want to do some kind of area weighted average.

Other useful code.

The following code snippet is the magic source that takes a polygon and loads just the part of a raster that intersects that polygon and loads just those cells into a NumPy array. We use this in BRAT. Note that the Rasterio mask method takes a parameter that determines whether to include all cells that touch the polygon or just those inside the polygon. given the 900m cell resolution you'll have to test this carefully.

https://github.com/Riverscapes/riverscapes-tools/blob/master/lib/commons/rscommons/raster_buffer_stats.py#L125

Also note that the polygon must be in the same spatial reference as the raster or you get an empty array back. We have lots of examples that reproject geometries. The trick will be loading the bespoke NOAA spatial reference from the MODIS rasters.

Note that raster spatial references and vector spatial references are represented by different object types in Python. Ping me or Matt about this.

Pseudo Code

create_sqlite_database

open a single MODIS raster and load its projection

create transform from NHD projection to MODIS projection

# There will be > 100,000 reaches. Matt has good code for batching such tasks
for reach in all_reaches:
  load_catchment_polygon
  transform_catchment_polygon to raster SRS
  
  for image in all_images:
    mask = raster_buffer_stats(polygon, image)
    # do some area weighted magic on the mask array here.
    avg_lst = np.average(mask)
		insert_lst_into_sqlite    
      

BRAT: Diversions Not Capturing all points

In the conflict attributes calculation we intersect canals with reach polylines to determine the points of diversion. This is not working 100% and only finding some of the connections.

We suspect that this is because although the canal and reach geometries appear to touch, they are in fact a very small distance apart. This could simply be down to imprecision in the geometry coordinates failing to satisfy the Shapely intersect routine.

In the following image, note the places where the reaches (blue) touch the canals (yellow) but no diversion point is identified.

2020-07-14

Max Drainage for Hydro region 17

I have synthesized all the drainage area and bankfull values for every reach in hydro region 17.ย 

The drainage area values come from NHDPlusHR and represent the total drainage area upstream of each reach. The bankfull values come from the Beechie and Imachi equation for the Columbia. The following scatter plot shows the results for all 2.8 million reaches in hydro region 17.

max_drainage

My goal was to be able to use these values to derive the BRAT threshold drainage area for each HUC above which discharges are too large for beaver dams. I queried the results by selecting the maximum drainage area in each HUC where the bankfull exceeds 20m. By way of verifying the resultsย I then plotted these values against those derived by USU for BRAT in Idaho. The results are not very encouraging:

idaho_compare

I also tried the min and the average drainage area for reaches above 20m bankfull width. They all produced similar results.

@joewheaton @wally-mac @tyler1218hatch let's meet to discuss please.

PRISM Bankfull width hardening when areas are invalid

Sometimes areas are null and sometimes areas are negative:

Check out these erroneous lines exported from rs_context/17110015/hydrology/NHDFlowline.shp

https://docs.google.com/spreadsheets/d/1uBxOxIk5Jy7v8L976qSL9Y7C4fvmwI6i_535fbQNBUE/edit?usp=sharing

This is the first time I've seen anything like this. All the 1711 hucs have this problem so it's probably a VPU error of some kind

@philipbaileynar let's discuss possible solutions tomorrow

My suggestion is that we just ignore anything that is null or <0

iPC_RoadVB values are too high in some watersheds.

In the North For John Day watershed, all iPC_RoadVB values are above 179,000 indicating that the closest road to any segment is still 179 km. away, which is not true. I'm not sure exactly what's happening here, or why it only happened in the North Fork John Day.
image
image

Dam Observation Reach Assignment

One of the last tasks to implement in sqlBRAT is assigning actual dam observation data to reaches. I am curious how this was done in pyBRAT @wally-mac and @tyler1218hatch ?

I have all the observation data for each HUC stored in the BRAT database along with the reaches and I'm ready to assign each dam observation to a reach. My plan is to loop over all the observations in a watershed and buffer them by some nominal amount, say 5m, and then look for reaches within this buffer polygon. I will repeat this process, incrementally growing the buffer by some nominal increment until the nearest reach is found.

If multiple reaches are found in any particular buffer then I can resolve using a distance calculation.

I think this will work. It should also be fairly efficient because there are typically few observations relative to the number of reaches within a watershed.

@wally-mac , @tyler1218hatch @MattReimer any thoughts on this?

BRAT param equation issues

@tyler1218hatch I just tried to pull the latest BRAT parameters and got this error. Looks like either the ELEV parameter is missing or you meant to reference a different parameter?

Hydrologic equation Error

Equation: 0.0000115 * (DRNAREA**0.837) * ((ELEV/1000)**4.658)
Exception: TypeError("'NoneType' object is not subscriptable")
Watersheds:
        16040101:
                FOREST: 1.6420786
                PRECIP: 356.84415
                ELEV1K: 1870.9065
                FORESTP1: 2.6420786
                DRNAREA: 1.0
        16040102:
                FOREST: 0.29267722
                PRECIP: 349.10995
                ELEV1K: 1933.643
                FORESTP1: 1.2926773
                DRNAREA: 1.0
        16040103:
                FOREST: 4.6637697
                PRECIP: 365.10788
                ELEV1K: 1931.519
                FORESTP1: 5.6637697
                DRNAREA: 1.0
        16040104:
                FOREST: 4.783619
                PRECIP: 295.56625
                ELEV1K: 1887.179
                FORESTP1: 5.783619
                DRNAREA: 1.0
        16040106:
                FOREST: 0.3168627
                PRECIP: 299.16714
                ELEV1K: 1741.8224
                FORESTP1: 1.3168627
                DRNAREA: 1.0
        16040109:
                FOREST: 0.70774484
                PRECIP: 354.66464
                ELEV1K: 1659.1447
                FORESTP1: 1.7077448
                DRNAREA: 1.0
        16040201:
                FOREST: 0.38978285
                PRECIP: 307.46912
                CANOPY_PCT: 0.11628719
                ELEV1K: 1515.3945
                FORESTP1: 1.3897828
                SOILCAPACITY: 113.835396
                I24H2Y: 120521.02
                JANMAXT2K: 0.32
                JANMINT2K: -4.65
                DRNAREA: 1.0
        16040202:
                FOREST: 0.29409057
                PRECIP: 246.45192
                ELEV1K: 1465.2488
                FORESTP1: 1.2940905
                DRNAREA: 1.0

CRB Hydrologic Equations Producing Irrational Numbers

@tyler1218hatch more problematic equations. This time I think it's negative January temperatures producing irrational numbers when raised to a negative power. Could this be a unit problem?

Hydrologic equation Error

Equation: 0.003119*(DRNAREA**1.021)*(MEANSLOPE**0.8124)*(I24H2Y**2.050)*(JANMINT2K**3.541)*(JANMAXT2K**-1.867)
Exception: TypeError("can't convert complex to float")
Watersheds:
        17050109:
                PRECIP: 274.95816
                RR: 1246.6797
                ELEV: 1371.0231
                MINELEV: 1016.43
                MEANSLOPE: 3.2464309
                SLOP30_30M: 0.1350555
                FOREST: 0.00381397
                ELEV1K: 1371.0231
                FORESTP1: 1.003814
                JANMINT2K: -2.79
                JANMAXT2K: 0.18
                SOILCAPACITY: 100.567055
                CANOPY_PCT: 0.003723105
                MAXELEV: 2110.0
                MINANTEMP: 34.598064
                SOILPERM: 2.4656503
                I24H2Y: 110414.94
                DRNAREA: 1.0
        17050110:
                PRECIP: 291.2323
                RR: 1321.5748
                ELEV: 1232.6617
                MINELEV: 666.246
                MEANSLOPE: 6.478775
                SLOP30_30M: 1.7708977
                FOREST: 0.4219328
                ELEV1K: 1232.6617
                FORESTP1: 1.4219328
                JANMINT2K: -3.17
                JANMAXT2K: -0.65
                SOILCAPACITY: 94.276146
                CANOPY_PCT: 0.09494064
                MAXELEV: 1947.0
                MINANTEMP: 34.765537
                SOILPERM: 1.9938973
                I24H2Y: 106720.82
                DRNAREA: 1.0
        17050116:
                PRECIP: 407.9049
                RR: 1722.5485
                ELEV: 1431.9598
                MINELEV: 890.52893
                MEANSLOPE: 8.091805
                SLOP30_30M: 0.69872385
                FOREST: 29.705196
                ELEV1K: 1431.9598
                FORESTP1: 30.705196
                JANMINT2K: -6.8
                JANMAXT2K: -0.63
                SOILCAPACITY: 113.137375
                CANOPY_PCT: 8.988988
                MAXELEV: 2484.0
                MINANTEMP: 31.909628
                SOILPERM: 1.0564604
                I24H2Y: 128678.586
                DRNAREA: 1.0
        17050117:
                PRECIP: 278.69293
                RR: 1169.9333
                ELEV: 1068.4752
                MINELEV: 650.06226
                MEANSLOPE: 8.26989
                SLOP30_30M: 1.2918402
                FOREST: 1.4113858
                ELEV1K: 1068.4752
                FORESTP1: 2.4113858
                JANMINT2K: -3.78
                JANMAXT2K: -1.18
                SOILCAPACITY: 115.467834
                CANOPY_PCT: 0.18149832
                MAXELEV: 1764.0
                MINANTEMP: 35.80414
                SOILPERM: 0.9242236
                I24H2Y: 102005.54
                DRNAREA: 1.0
        17050118:
                PRECIP: 308.0869
                RR: 1293.573
                ELEV: 1219.2351
                MINELEV: 683.61316
                MEANSLOPE: 9.039434
                SLOP30_30M: 0.66309094
                FOREST: 5.8415256
                ELEV1K: 1219.2351
                FORESTP1: 6.8415256
                JANMINT2K: -3.92
                JANMAXT2K: -1.86
                SOILCAPACITY: 98.4345
                CANOPY_PCT: 0.64705765
                MAXELEV: 1902.0
                MINANTEMP: 33.87078
                SOILPERM: 0.7264646
                I24H2Y: 128356.08
                DRNAREA: 1.0
        17050119:
                PRECIP: 326.3961
                RR: 1702.6364
                ELEV: 1155.323
                MINELEV: 680.11096
                MEANSLOPE: 8.381586
                SLOP30_30M: 0.8832137
                FOREST: 5.9036655
                ELEV1K: 1155.323
                FORESTP1: 6.9036655
                JANMINT2K: -5.34
                JANMAXT2K: -1.63
                SOILCAPACITY: 119.55975
                CANOPY_PCT: 1.4994221
                MAXELEV: 2195.0
                MINANTEMP: 34.170048
                SOILPERM: 0.95492065
                I24H2Y: 118138.695
                DRNAREA: 1.0
        17050202:
                PRECIP: 435.25244
                RR: 1767.875
                ELEV: 1366.405
                MINELEV: 624.50385
                MEANSLOPE: 12.75418
                SLOP30_30M: 3.112396
                FOREST: 33.62548
                ELEV1K: 1366.405
                FORESTP1: 34.62548
                JANMINT2K: -5.67
                JANMAXT2K: -1.73
                SOILCAPACITY: 121.79346
                CANOPY_PCT: 12.742447
                MAXELEV: 2269.0
                MINANTEMP: 32.7578
                SOILPERM: 1.2915592
                I24H2Y: 127241.06
                DRNAREA: 1.0
        17050203:
                PRECIP: 577.62225
                RR: 2289.5332
                ELEV: 1324.7931
                MINELEV: 627.92487
                MEANSLOPE: 10.609335
                SLOP30_30M: 3.6978602
                FOREST: 36.93767
                ELEV1K: 1324.7931
                FORESTP1: 37.93767
                JANMINT2K: -7.62
                JANMAXT2K: -1.12
                SOILCAPACITY: 125.99198
                CANOPY_PCT: 15.226885
                MAXELEV: 2722.0
                MINANTEMP: 32.43788
                SOILPERM: 1.1138145
                I24H2Y: 139957.9
                DRNAREA: 1.0
        17060102:
                PRECIP: 714.6871
                RR: 2669.0095
                ELEV: 1482.9218
                MINELEV: 287.0023
                MEANSLOPE: 19.358786
                SLOP30_30M: 19.586037
                FOREST: 50.664177
                ELEV1K: 1482.9218
                FORESTP1: 51.664177
                JANMINT2K: -7.77
                JANMAXT2K: 2.52
                SOILCAPACITY: 117.06567
                CANOPY_PCT: 19.580297
                MAXELEV: 2770.0
                MINANTEMP: 32.430527
                SOILPERM: 0.9702837
                I24H2Y: 154732.39
                DRNAREA: 1.0
        17060104:
                PRECIP: 709.1687
                RR: 1946.395
                ELEV: 1268.4661
                MINELEV: 696.802
                MEANSLOPE: 9.342999
                SLOP30_30M: 1.8903265
                FOREST: 65.55148
                ELEV1K: 1268.4661
                FORESTP1: 66.55148
                JANMINT2K: -6.58
                JANMAXT2K: -0.11
                SOILCAPACITY: 163.92236
                CANOPY_PCT: 26.025047
                MAXELEV: 2493.0
                MINANTEMP: 33.348278
                SOILPERM: 1.2566912
                I24H2Y: 164413.7
                DRNAREA: 1.0
        17060105:
                PRECIP: 801.2402
                RR: 2299.9355
                ELEV: 1553.2351
                MINELEV: 697.1409
                MEANSLOPE: 14.698519
                SLOP30_30M: 11.34359
                FOREST: 56.050365
                ELEV1K: 1553.2351
                FORESTP1: 57.050365
                JANMINT2K: -7.77
                JANMAXT2K: -0.22
                SOILCAPACITY: 160.8742
                CANOPY_PCT: 21.73657
                MAXELEV: 2870.0
                MINANTEMP: 30.126585
                SOILPERM: 1.5479754
                I24H2Y: 160400.48
                DRNAREA: 1.0
        17060106:
                PRECIP: 599.03455
                RR: 1697.4656
                ELEV: 1209.027
                MINELEV: 250.19669
                MEANSLOPE: 15.556103
                SLOP30_30M: 14.242556
                FOREST: 57.594707
                ELEV1K: 1209.027
                FORESTP1: 58.594707
                JANMINT2K: -4.11
                JANMAXT2K: 2.8
                SOILCAPACITY: 138.99663
                CANOPY_PCT: 22.329958
                MAXELEV: 1870.0
                MINANTEMP: 35.142212
                SOILPERM: 0.92556864
                I24H2Y: 132021.52
                DRNAREA: 1.0
        17070201:
                PRECIP: 469.06387
                RR: 2730.4363
                ELEV: 1388.1428
                MINELEV: 25.635927
                MEANSLOPE: 13.044097
                SLOP30_30M: 3.2394245
                FOREST: 58.581425
                ELEV1K: 1388.1428
                FORESTP1: 59.581425
                JANMINT2K: -7.05
                JANMAXT2K: 2.47
                SOILCAPACITY: 131.00137
                CANOPY_PCT: 19.649551
                MAXELEV: 2549.0
                MINANTEMP: 33.127003
                SOILPERM: 0.896482
                I24H2Y: 143066.31
                DRNAREA: 1.0
        17070203:
                PRECIP: 508.50555
                RR: 1811.3674
                ELEV: 1377.8085
                MINELEV: 668.0266
                MEANSLOPE: 10.683025
                SLOP30_30M: 1.209978
                FOREST: 67.555115
                ELEV1K: 1377.8085
                FORESTP1: 68.555115
                JANMINT2K: -6.34
                JANMAXT2K: 1.35
                SOILCAPACITY: 102.905304
                CANOPY_PCT: 25.81413
                MAXELEV: 2348.0
                MINANTEMP: 32.92665
                SOILPERM: 0.8628358
                I24H2Y: 150769.6
                DRNAREA: 1.0
        17070301:
                PRECIP: 835.2297
                RR: 2615.8289
                ELEV: 1307.0571
                MINELEV: 585.10065
                MEANSLOPE: 6.041021
                SLOP30_30M: 1.3677562
                FOREST: 68.04008
                ELEV1K: 1307.0571
                FORESTP1: 69.04008
                JANMINT2K: -7.12
                JANMAXT2K: 1.54
                SOILCAPACITY: 161.01509
                CANOPY_PCT: 30.390985
                MAXELEV: 2995.0
                MINANTEMP: 31.895506
                SOILPERM: 6.3370924
                I24H2Y: 234767.66
                DRNAREA: 1.0
        17070302:
                PRECIP: 747.17694
                RR: 1397.2194
                ELEV: 1513.2972
                MINELEV: 1267.4581
                MEANSLOPE: 4.364494
                SLOP30_30M: 0.39984763
                FOREST: 82.66095
                ELEV1K: 1513.2972
                FORESTP1: 83.66095
                JANMINT2K: -4.33
                JANMAXT2K: -0.43
                SOILCAPACITY: 237.31645
                CANOPY_PCT: 42.200577
                MAXELEV: 2405.0
                MINANTEMP: 29.474653
                SOILPERM: 11.975175
                I24H2Y: 193151.25
                DRNAREA: 1.0
        17070303:
                PRECIP: 347.32895
                RR: 1081.0232
                ELEV: 1405.103
                MINELEV: 1104.1704
                MEANSLOPE: 4.3763037
                SLOP30_30M: 0.099324524
                FOREST: 18.753382
                ELEV1K: 1405.103
                FORESTP1: 19.753382
                JANMINT2K: -3.75
                JANMAXT2K: -0.65
                SOILCAPACITY: 100.09471
                CANOPY_PCT: 3.1765206
                MAXELEV: 2007.0
                MINANTEMP: 30.014832
                SOILPERM: 1.6872092
                I24H2Y: 132498.69
                DRNAREA: 1.0
        17070304:
                PRECIP: 420.1934
                RR: 1126.1387
                ELEV: 1401.6792
                MINELEV: 986.0527
                MEANSLOPE: 7.6595907
                SLOP30_30M: 0.46975446
                FOREST: 55.361168
                ELEV1K: 1401.6792
                FORESTP1: 56.361168
                JANMINT2K: -4.03
                JANMAXT2K: 0.75
                SOILCAPACITY: 109.75469
                CANOPY_PCT: 12.439555
                MAXELEV: 2054.0
                MINANTEMP: 31.780035
                SOILPERM: 0.96787566
                I24H2Y: 143922.28
                DRNAREA: 1.0
        17070305:
                PRECIP: 321.54727
                RR: 1753.2673
                ELEV: 1273.52
                MINELEV: 589.93726
                MEANSLOPE: 5.6152954
                SLOP30_30M: 0.6680608
                FOREST: 43.27156
                ELEV1K: 1273.52
                FORESTP1: 44.27156
                JANMINT2K: -4.0
                JANMAXT2K: 1.6
                SOILCAPACITY: 124.69173
                CANOPY_PCT: 10.783437
                MAXELEV: 2256.0
                MINANTEMP: 31.860582
                SOILPERM: 4.6369233
                I24H2Y: 138509.14
                DRNAREA: 1.0
        17070307:
                PRECIP: 344.1816
                RR: 1417.5803
                ELEV: 994.03534
                MINELEV: 391.06897
                MEANSLOPE: 9.190718
                SLOP30_30M: 1.433836
                FOREST: 31.41921
                ELEV1K: 994.03534
                FORESTP1: 32.419212
                JANMINT2K: -2.44
                JANMAXT2K: 2.03
                SOILCAPACITY: 154.44513
                CANOPY_PCT: 5.403743
                MAXELEV: 1747.0
                MINANTEMP: 35.65968
                SOILPERM: 0.57735044
                I24H2Y: 142251.06
                DRNAREA: 1.0
        17090001:
                PRECIP: 1756.8977
                RR: 2528.9941
                ELEV: 995.0496
                MINELEV: 134.03691
                MEANSLOPE: 15.527615
                SLOP30_30M: 9.474728
                FOREST: 88.20227
                ELEV1K: 995.0496
                FORESTP1: 89.20227
                JANMINT2K: -4.21
                JANMAXT2K: 5.14
                SOILCAPACITY: 163.84691
                CANOPY_PCT: 64.92189
                MAXELEV: 2471.0
                MINANTEMP: 37.27921
                SOILPERM: 1.8832479
                I24H2Y: 358272.88
                DRNAREA: 1.0
        17090004:
                PRECIP: 2098.1206
                RR: 3064.1045
                ELEV: 960.51154
                MINELEV: 87.039215
                MEANSLOPE: 14.487261
                SLOP30_30M: 10.37041
                FOREST: 84.16528
                ELEV1K: 960.51154
                FORESTP1: 85.16528
                JANMINT2K: -6.03
                JANMAXT2K: 5.31
                SOILCAPACITY: 165.2653
                CANOPY_PCT: 61.674095
                MAXELEV: 2977.0
                MINANTEMP: 36.893463
                SOILPERM: 2.754843
                I24H2Y: 404541.38
                DRNAREA: 1.0
        17100301:
                ELEV: 1013.6238
                FOREST: 31.565908
                PRECIP: 1495.7584
                MINELEV: 117.0
                MEANSLOPE: 9.739323
                CANOPY_PCT: 61.707397
                SOILPERM: 2.299652
                JANMAXT2K: 6.06
                I24H2Y: 343922.03
                ELEV1K: 1013.6238
                FORESTP1: 32.565907
                JANMINT2K: -4.18
                SOILCAPACITY: 164.94603
                MINANTEMP: 37.106327
                MAXELEV: 2406.0
                DRAINDENS: 2.5682266
                DRNAREA: 1.0
        17100307:
                ELEV: 1140.0234
                FOREST: 39.20119
                PRECIP: 1142.5096
                MINELEV: 371.0
                MEANSLOPE: 7.680228
                CANOPY_PCT: 55.264156
                SOILPERM: 2.1515472
                JANMAXT2K: 4.8
                I24H2Y: 303896.34
                ELEV1K: 1140.0234
                FORESTP1: 40.20119
                JANMINT2K: -4.09
                SOILCAPACITY: 153.48372
                MINANTEMP: 36.307133
                MAXELEV: 2687.0
                DRAINDENS: 2.5224948
                DRNAREA: 1.0
        17100309:
                ELEV: 953.2972
                FOREST: 32.325546
                PRECIP: 922.454
                MINELEV: 266.0
                MEANSLOPE: 11.781125
                CANOPY_PCT: 61.612244
                SOILPERM: 1.59632
                JANMAXT2K: 5.32
                I24H2Y: 316481.2
                ELEV1K: 953.2972
                FORESTP1: 33.325546
                JANMINT2K: -1.15
                SOILCAPACITY: 123.94441
                MINANTEMP: 39.673977
                MAXELEV: 2152.0
                DRAINDENS: 3.0035133
                DRNAREA: 1.0
        17120001:
                ELEV: 1375.1982
                FOREST: 2.4278853
                PRECIP: 310.78586
                MINELEV: 1250.0
                MEANSLOPE: 1.9900857
                CANOPY_PCT: 2.4989402
                SOILPERM: 1.0640485
                JANMAXT2K: -0.58
                I24H2Y: 105399.17
                ELEV1K: 1375.1982
                FORESTP1: 3.4278853
                JANMINT2K: -3.45
                SOILCAPACITY: 110.09708
                MINANTEMP: 31.503723
                MAXELEV: 2089.0
                DRNAREA: 1.0
        17120002:
                ELEV: 1506.7325
                FOREST: 15.2738905
                PRECIP: 412.60547
                MINELEV: 1251.0
                MEANSLOPE: 3.1497371
                CANOPY_PCT: 16.873676
                SOILPERM: 1.064889
                JANMAXT2K: -2.06
                I24H2Y: 123209.305
                ELEV1K: 1506.7325
                FORESTP1: 16.273891
                JANMINT2K: -6.24
                SOILCAPACITY: 157.8029
                MINANTEMP: 29.448797
                MAXELEV: 2475.0
                DRNAREA: 1.0
        17120003:
                ELEV: 1636.8096
                FOREST: 3.768669
                PRECIP: 458.85062
                MINELEV: 1250.0
                MEANSLOPE: 4.2645516
                CANOPY_PCT: 3.0611377
                SOILPERM: 1.5354198
                JANMAXT2K: -0.11
                I24H2Y: 121652.65
                ELEV1K: 1636.8096
                FORESTP1: 4.768669
                JANMINT2K: -6.55
                SOILCAPACITY: 98.57984
                MINANTEMP: 32.90096
                MAXELEV: 2869.0
                DRNAREA: 1.0
        17120004:
                ELEV: 1443.5358
                FOREST: 4.668261
                PRECIP: 290.6993
                MINELEV: 1251.0
                MEANSLOPE: 1.9046344
                CANOPY_PCT: 3.7066453
                SOILPERM: 1.0377738
                JANMAXT2K: -0.94
                I24H2Y: 119496.23
                ELEV1K: 1443.5358
                FORESTP1: 5.668261
                JANMINT2K: -3.53
                SOILCAPACITY: 94.020515
                MINANTEMP: 30.35022
                MAXELEV: 1942.0
                DRNAREA: 1.0
        17120005:
                ELEV: 1472.5276
                FOREST: 7.626231
                PRECIP: 309.70416
                MINELEV: 1266.0
                MEANSLOPE: 2.5314064
                CANOPY_PCT: 8.432043
                SOILPERM: 4.7820516
                JANMAXT2K: 0.4
                I24H2Y: 136358.28
                ELEV1K: 1472.5276
                FORESTP1: 8.626231
                JANMINT2K: -3.78
                SOILCAPACITY: 135.23259
                MINANTEMP: 29.999802
                MAXELEV: 2311.0
                DRNAREA: 1.0
        17120006:
                ELEV: 1584.5181
                FOREST: 10.501575
                PRECIP: 359.92157
                MINELEV: 1298.0
                MEANSLOPE: 5.0054836
                CANOPY_PCT: 12.891749
                SOILPERM: 2.1006358
                JANMAXT2K: 0.09
                I24H2Y: 136093.03
                ELEV1K: 1584.5181
                FORESTP1: 11.501575
                JANMINT2K: -4.32
                SOILCAPACITY: 118.7769
                MINANTEMP: 31.937597
                MAXELEV: 2443.0
                DRNAREA: 1.0
        17120007:
                ELEV: 1635.1797
                FOREST: 4.330356
                PRECIP: 312.7129
                MINELEV: 1357.0
                MEANSLOPE: 3.9709196
                CANOPY_PCT: 4.3811135
                SOILPERM: 1.9275321
                JANMAXT2K: 0.12
                I24H2Y: 124262.586
                ELEV1K: 1635.1797
                FORESTP1: 5.330356
                JANMINT2K: -4.42
                SOILCAPACITY: 104.24127
                MINANTEMP: 32.502777
                MAXELEV: 2467.0
                DRNAREA: 1.0
        17120008:
                ELEV: 1647.4011
                FOREST: 0.2106936
                PRECIP: 281.3964
                MINELEV: 1379.0
                MEANSLOPE: 2.5000494
                CANOPY_PCT: 0.15518954
                SOILPERM: 1.1268537
                JANMAXT2K: 0.01
                I24H2Y: 118236.13
                ELEV1K: 1647.4011
                FORESTP1: 1.2106936
                JANMINT2K: -4.22
                SOILCAPACITY: 107.661896
                MINANTEMP: 32.14094
                MAXELEV: 2382.0
                DRNAREA: 1.0
        17120009:
                ELEV: 1501.7438
                FOREST: 0.27065974
                PRECIP: 323.4024
                MINELEV: 1196.0
                MEANSLOPE: 5.2527685
                CANOPY_PCT: 0.2746437
                SOILPERM: 2.0840845
                JANMAXT2K: 0.19
                I24H2Y: 117450.695
                ELEV1K: 1501.7438
                FORESTP1: 1.2706597
                JANMINT2K: -6.69
                SOILCAPACITY: 87.62227
                MINANTEMP: 35.128704
                MAXELEV: 2838.0
                DRNAREA: 1.0

UK BRAT - Scope merging back into sqlBRAT

Hugh Graham (@h-a-graham) just published the UK BRAT or BDC (beaver dam capacity) model and a new BFI (beaver foraging index). Both are based off of the pyBRAT.

Graham et al. - 2020 - Modelling Eurasian beaver foraging habitat and dam.pdf

All of @h-a-graham source code can be found at https://github.com/h-a-graham/Graham_et_al._in_review_Supporting-Information

The Task

First we should take a look at this and scope what it would take to:

  • Integrate the UK BDC into sqlBRAT
  • Run BRAT with the UK and European data sources highlighted in paper
  • Build a UK Riverscapes Context project from those data sources and a UK National Model
  • Integrate the BFI as something that can run anywhere BRAT runs.

This will all take $$ but I'd like to scope it and get a meeting together with @h-a-graham, Allan Puttock and Richard Brazier to discuss seeking funding. As a teaser, here's a UK wide run they're working on (provisional):
England_BDC

Getting Thiessen Polygons Working

@MattReimer I have stubbed out the new version of the Riparian Vegetation Departure (RVD). It's on a branch called rvd. This involved moving more generic code from sqlBRAT and moving up into RSCommons. e.g. database.py, report.py. I was careful and ran all our existing tools on a single HUC as a regression test.

RVD uses Thiessen polygons. I have copied over the Thiessen code from the old rivertools repo and put it in RSCommons. But I can't get it to work. Something to do with scipy.spatial. Intellisense seems know about this module, but perhaps it needs separate installation?

Anyway, can you please enhance RVD so that it produces a ShapeFile of Thiessen polygons around the segmented reach polylines. The goal is a ShapeFile of one polygon per segmented reach polyline. The reach polylines are stored in the segmented.shp intermediate ShapeFile and uniquely identified by ReachID.

I'm confident that if we can explode the reach lines to vertex points and then produce a Thiessen polygon for each point. The question then becomes how do we union together the polygons for all points with the same ReachID? See the bottom figure here for a cartoon of what this should look like (after the subsequent step of clipping the Thiessen polygons with the valley bottom).

Difference between NHD Flowlines Input & VBET Network?

So after snooping around at the Inputs\flowlines.shp or NHD Flowlines and the Intermediates\vbet_network.shp or VBET Network, I realized what you are using as the input from FCode list.

So, first thing is that the NHD Flowlines has everything we want and then some:
image

The then some we need to think carefully about are canals (33600). I don't think we need them.

What VBET is doing now?

As I asked in Riverscapes/vbet#1, I still don't have a clear answer to what VBET is producing VBET Network from, but as indicated in #11 I think we need to anticipate that this is the key thing a user wants to change or tweak.

Illustrated with the Yampa, you're only giving me the 3360 km of the 13,625 km in he NHD Network.
image

It appears you are already giving us the (33400) and artificial paths (55800). However, you are inconsistent on which of the others you give us (I found a few intermittent 46003
NHD Flowlines.zip

)
image

What VBET should do for VBET Network?

Short-term for Production Grade Anabranch runs

Please update your default to include all the ones in boxed red:
image

In Medium-Term for Commercial Grade

Expose to user the choice of what FCodes to use.

Cashe, I uploaded the layer file I am using for NHD lines.

NHD Flowlines.zip

Likelihood of being a Valley Bottom Raster

I would like to emphasize the output of the new VBET that comes out of the box as a likelihood of being a valley bottom cell. This value (between 0 & 100%) we will need @wally-mac and crew to develop a reasonable categorical break and symbology for.

A helpful byproduct would be contours at 10% increments.

See also Riverscapes/vbet#4

Remove legacy riverscapes developers

@joewheaton can we purge legacy developers from the riverscapes GitHub organization?

I described to you recently that the industry standard practice for collaboration within GitHub is to keep the developer teams small. External contributors can fork any riverscapes repo, make changes to their own forked copy and contribute their changes back to the official riverscapes repos using pull requests. Contributors do not need to be members of the riverscapes development team to do this. Any GitHub user can do this.

Please approve the cleanup of the riverscapes organization GitHub teams and removal of anyone who is a member of Anabranch, USU ET AL or NAR. People like Matt Nahorniak and Pete McHugh.

GitHub has lots of resources (documentation and videos) outlining the workflow that I describe above. We can link to these materials from "how-to" pages on the main riverscapes.xyz web site and also the riverscapes GitHub organization page.

Why do to this effort?

  1. It's the industry best practice.
  2. The effort to maintain permissions grows exponentially as we continually add repos.
  3. We now have several repos serving public facing services. We are trying to keep the master branches locked down to only the build master (@MattReimer) as a way of reducing the risk of breaking production systems. But this is fiddly and complicated when there are dozens of members of the organization.
  4. Day-to-day activities like assigning issues will be faster when the dropdown lists don't also contain my Mum's second cousin twice removed!!!!!!

Improved Land Ownership Symbology

Please add the following categories to the land ownership symbology used for riverscapes context projects. The particular colors are not important. Just use something consistent with those already there:

  • NPS - National Parks Service
  • FWS - Fish and wildlife service

If you need a specific riverscapes project to test these out then use the new 18040009 which has NPS land.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.