Skip to main content

Generate curvilinear mesh from river outline polygons

Project description

https://raw.githubusercontent.com/cheginit/curviriver/main/doc/source/_static/logo-text.png

CurviRiver: Curvilinear Mesh Generator for Rivers

CI PyPi Conda Version CodeCov Python Versions

Downloads CodeFactor black pre-commit

Features

CurviRiver takes as input a Polygon of a river segment and generates a 2D or 3D curvilinear mesh that can be used for hydrodynamic or hydrological modeling. The mesh is generated in three main steps:

  • Determining the centerline of the input Polygon using Voroni diagram Dijkstra’s algorithm,

  • Smoothing the generated centerline with a B-spline curve,

  • Computing the tangent angles of the centerline at each point along the centerline and generating cross-sections perpendicular to the centerline at given intervals,

  • Generating a 2D mesh from vertices of the cross-sections,

  • Generating a 3D mesh if depth data is provided, by determining the depth of 2D mesh vertices from the depth data using Inverse Distance Weighting (IDW).

Installation

You can install CurviRiver using pip:

$ pip install curviriver

or using conda (mamba):

$ conda install -c conda-forge curviriver

Quick start

We demonstrate capabilities of CurviRiver by generating a curvilinear mesh along a portion of the Columbia River and interpolating eHydro topobathy data on to the generated mesh vertices. Please visit the example gallery for more examples.

First, we use PyGeoHydro to retrieve eHydro data for a part of the Columbia River that topobathy data are available. We get both the survey outline and the bathymetry data. Then, we use the survey outline polygon to generate a curvilinear mesh. We use the poly_segmentize function for this purpose that has two parameters: Spacing in streamwise direction and number of points in cross-stream direction. The function returns a geopandas.GeoSeries of the cross-sections, vertices of which are the mesh points.

from pygeohydro import EHydro
import curviriver as cr

ehydro = EHydro("outlines")
geom = ehydro.survey_grid.loc[ehydro.survey_grid["OBJECTID"] == 210, "geometry"].iloc[0]
outline = ehydro.bygeom(geom, ehydro.survey_grid.crs)

poly = outline.convex_hull.unary_union
spacing_streamwise = 2000
xs_npts = 5
stream = cr.poly_segmentize(poly, outline.crs, spacing_streamwise, xs_npts)
https://raw.githubusercontent.com/cheginit/curviriver/main/doc/source/_static/curvilinear.png

Contributing

Contributions are very welcomed. Please read CONTRIBUTING.rst file for instructions.

Support

The work for this project is funded by USGS through Water Resources Research Institutes (WRRI).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

curviriver-0.1.0.tar.gz (999.8 kB view hashes)

Uploaded Source

Built Distribution

curviriver-0.1.0-py3-none-any.whl (17.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page