curviriver.curvilinear#

Generate curvilinear mesh from a polygon.

Module Contents#

curviriver.curvilinear.line_extension(line, poly, both_ends=True)[source]#

Extend a line to the boundary of a (multi)polygon.

Parameters:
Returns:

shapely.LineString – Extended line.

Return type:

shapely.LineString

curviriver.curvilinear.line_xsection(line, distance, width, crs)[source]#

Get cross-sections along the line at a given spacing.

Parameters:
  • line (shapely.LineString) – A line along which the cross-sections will be generated.

  • distance (float) – The distance between two consecutive cross-sections.

  • width (float) – The width of the cross-section.

  • crs (str or int or pyproj.CRS) – The CRS of the input line. Using projected CRS is highly recommended.

Returns:

geopandas.GeoSeries – Cross-sections along the line, sorted by line direction.

Return type:

geopandas.GeoSeries

curviriver.curvilinear.poly_centerline(geometry)[source]#

Create centerline from a polygon.

This function is based on the Centerline package (MIT License).

Parameters:

geometry (shapely.Polygon or shapely.MultiPolygon) – Input geometry which can be either Polygon` or MultiPolygon.

Returns:

shapely.LineString – Centerline of the input geometry

Return type:

shapely.LineString

curviriver.curvilinear.poly_segmentize(poly, crs, spacing_streamwise, xs_npts)[source]#

Segmentize a polygon into a curvilinear grid.

Parameters:
  • poly (shapely.Polygon) – Polygon to convert to a grid of transects.

  • crs (int, str, or pyproj.CRS) – Coordinate reference system of the polygon. Using projected CRS is highly recommended.

  • spacing_streamwise (float) – Spacing between cross-sections along the polygon’s centerline.

  • xs_npts (int) – Number of points along each cross-section.

Returns:

gpd.GeoSeries – Cross-sections as a GeoSeries of LineStrings.

Return type:

geopandas.GeoSeries