API

Module contents

Submodules

centerline.exceptions module

exception centerline.exceptions.CenterlineError(*args, **kwargs)[source]

Bases: Exception

default_message = 'An error has occured while constucting the centerline.'
exception centerline.exceptions.InvalidInputTypeError(*args, **kwargs)[source]

Bases: CenterlineError

default_message = 'Input geometry must be of type shapely.geometry.Polygon or shapely.geometry.MultiPolygon!'
exception centerline.exceptions.TooFewRidgesError(*args, **kwargs)[source]

Bases: CenterlineError

default_message = 'Number of produced ridges is too small. Please adjust your interpolation distance.'
exception centerline.exceptions.UnsupportedVectorType(*args, **kwargs)[source]

Bases: CenterlineError

default_message = 'No OGR driver was found for the provided file.'

centerline.converters module

centerline.converters.get_ogr_driver(filepath)[source]

Get the OGR driver based on the file’s extension.

Parameters:

filepath (str) – file’s path

Raises:

UnsupportedVectorType – unsupported extension

Returns:

OGR driver

Return type:

osgeo.ogr.Driver

centerline.geometry module

class centerline.geometry.Centerline(input_geometry, interpolation_distance=0.5, **attributes)[source]

Bases: object

Create a centerline object.

The attributes are copied and set as the centerline’s attributes.

Parameters:
  • input_geometry (shapely.geometry.Polygon or shapely.geometry.MultiPolygon) – input geometry

  • interpolation_distance (float, optional) – densify the input geometry’s border by placing additional points at this distance, defaults to 0.5 [meter]

Raises:

exceptions.InvalidInputTypeError – input geometry is not of type shapely.geometry.Polygon or shapely.geometry.MultiPolygon

assign_attributes_to_instance(attributes)[source]

Assign the attributes to the Centerline object.

Parameters:

attributes (dict) – polygon’s attributes

input_geometry_is_valid()[source]

Input geometry is of a shapely.geometry.Polygon or a shapely.geometry.MultiPolygon.

Returns:

geometry is valid

Return type:

bool