Utils

Utils#

Utils contains functions used across multiple classes to create, edit, and plot Structures.

azimuth(p1, p2)

Returns the azimuth angle between two points (from x-axis).

fmodnew(angle)

Modified modulo calculations for angles in degrees.

midpoint(p1, p2[, alpha])

Calculates the midpoint between two points.

mirror(object, aroundaxis[, origin])

Returns a mirrored object along a given axis "x" or "y".

append_line(line1, line2[, direction, ...])

Appends arbitrary line to another arbitrary line and Return the result.

buffer_along_path(points, widths)

Calculates a polygon (aka "buffer") along the path defined by the list of point and widths.

buffer_line_with_variable_width(line, ...[, ...])

Returns a buffered a line with variable widths along its length.

calculate_label_pos(x, y, centroid[, ...])

Calculates the position of the label in respect to the centroid of the polygon.

check_point_equality(p1, p2)

Checks whether two points are equal and raises a ValueError if they are.

combine_lines(line1, line2[, tol])

Combines two LineStrings by joining them together at their endpoints

to_geometry_list(geometry)

Returns a list of geometries from a given geometry object.

find_nearest_point_index(polygon, point)

Finds the index of the closest point in a Shapely polygon to a given point.

flatten_lines(line1, line2[, bypass_alignment])

Appends line2 to line1 and returning a new LineString object.

flatten_multipolygon(mp[, cut_position])

Removes holes from a MultiPolygon object containing Polygons with holes.

flatten_polygon(p[, cut_position])

Creates a cut line along the centroid of each hole and dissects the polygon.

get_abc_line(p1, p2)

Calculates the coefficients (a, b, c) of the line equation Ax + By + C = 0

get_intersection_point(abc1, abc2)

Calculates the intersection point of two lines represented by their coefficients.

get_intersection_point_bruteforce(p1, p2, p3, p4)

Calculates the intersection point between two line segments using a brute-force approach.

get_intersection_withoffset(pts, width)

Given three points and offset distances, calculates the coordinate of the offset point from the middle point.

get_normals_along_line(line, locs[, norm])

Calculates normal angles of a line at desired locations.

has_interior(p)

Determines if a polygon has any interior.

offset_point(point, offset, angle)

Offsets a point by a given distance and angle.

oriented_angle(p1, p2, p3)

Calculates oriented angle between vectors p1->p2 and p2->p3.

polygonize_text([text, size])

Converts text to a MultiPolygon geometry.

replace_closest_polygon(multipolygon, point, ...)

Replaces the closest polygon in a MultiPolygon with a new polygon.

round_corner(multipolygon, around_point, ...)

Rounds the corner of the closest polygon in a MultiPolygon around a given point with a specified radius.

round_polygon(polygon, round_radius, **kwargs)

Rounds the corners of a polygon by applying a buffer operation.

round_polygon_corner(polygon, corner_index)

Rounds one corner of a Shapely polygon.