Skip to content

Major refactor

Hopkins, Anders L requested to merge AH-11 into master

Merge Requests includes the major refactor to both the flowtrace and splitcatchment algorithms.

For splitcatchment, the algorithm clips the fdr to a 90 meter buffer of the catchment, looks to see if the delineation point/cell is on a flowline (cell intersects the NHD flowline and is on a FAC cell > 1100), then delineates with pyflwdir. If the delineation cell is on a flowline (and the user wants the upstream basin) then the splitcatchment is expanded slightly, and merged with a slightly expanded upstreambasin, then the output is shrunk slightly.

For the flowtrace algorithm, the flowpath starts with the clickpoint, then traces downstream until the NHD Flowline is intersected and the FAC value is greater than 1100. Then the flowpath goes downhill one extra cell. This extra downhill cell helps in the common situation where the NHD flowline overlaps a FAC cell greater than 1100, but that this is not the ‘main flow path’ through the catchment. This will result in a splitcatchment which does not include this main flowpath through the catchment, which when merged with the upstream basin, is clearly wrong. As stated, the first point of the flow path is the click point, then the next points are the cell centers of the flowtrace, then the last point is the midpoint of the NHD flowline clipped to the last cell’s boundary. The center point of the last cell is not included in the flowpath.

Updated the tests to reflect the changes above and to test with Python versions 3.9, 3.10, 3.11, and 3.12. New tests created for new functions added to the utils component. All the nox tests run successfully.

Fixes #5: Updated dependency conflicts to fix failing install.

Fixes #6: Testing was updated and all testing now pass successfully.

Fixes #7: Required files and documentation updated per reviewer's suggestions.

  • IP number, DOI number, and Disclaimer link added to the README
  • Added Center tag to code.json, updated edit date
  • Updated the working python versions: 3.9-3.12
  • References made in the README to NHDPlus V2 and the NLDI.
  • Dependencies simplified and rasterio no longer needs to be installed prior to NLDI-Flowtools
  • README now states that the package only works for lat, lon points in WGS84 and within CONUS
  • Updated the error handling during requests to the NLDI and GeoServer
  • Merge_geometry function has not been deprecated. Now, the to create the drainageBasin geometry, the splitcatchment and upstreamBasin are merged, but to prevent gaps, both geometries are buffered by a small amount before the merge, then an equal buffer is removed from the geometry after the merge.
  • Fleshed out the docstrings for utility functions
  • Added WGS84 as the required CRS for the input point coordinates.
  • Changed all instances of pour point to input point

Does not fix #8. This needs more attention. The flowtrace does not register a stream intersection before it flows out of the local catchment. This will require fetching the downstream catchment, flowline and FDR and FAC coverage for this downstream area.

Edited by Hopkins, Anders L

Merge request reports

Loading