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:
line (
shapely.LineString) – Line to be extended.poly (
shapely.Polygonorshapely.MultiPolygon) – Polygon to which the line will be extended.both_ends (
bool, optional) – Whether to extend both ends of the line, defaults toTrue.
- Returns:
shapely.LineString– Extended line.- Return type:
- 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 (
strorintorpyproj.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:
- curviriver.curvilinear.poly_centerline(geometry)[source]#
Create centerline from a polygon.
This function is based on the Centerline package (MIT License).
- Parameters:
geometry (
shapely.Polygonorshapely.MultiPolygon) – Input geometry which can be eitherPolygon`orMultiPolygon.- Returns:
shapely.LineString– Centerline of the input geometry- Return type:
- 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, orpyproj.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: