libpysal.cg.Chain

class libpysal.cg.Chain(vertices: list)[source]

Geometric representation of a chain, also known as a polyline.

Parameters
verticespython:list

A point list or list of point lists.

Examples

>>> c = Chain([Point((0, 0)), Point((1, 0)), Point((1, 1)), Point((2, 1))])
Attributes
verticespython:list

Returns the vertices of the chain in clockwise order.

lenpython:float

Returns the geometric length of the chain.

__init__(self, vertices: list)[source]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(self, vertices)

Initialize self.

Attributes

arclen

Returns the geometric length of the chain computed using ‘arcdistance’ (meters).

bounding_box

Returns the bounding box of the chain.

len

Returns the geometric length of the chain.

parts

Returns the parts (lists of libpysal.cg.Point objects) of the chain.

segments

Returns the segments that compose the chain.

vertices

Returns the vertices of the chain in clockwise order.

property arclen

Returns the geometric length of the chain computed using ‘arcdistance’ (meters).

property bounding_box

Returns the bounding box of the chain.

Returns
self._bounding_boxlibpysal.cg.Rectangle

The bounding box of the chain.

Examples

>>> c = Chain([Point((0, 0)), Point((2, 0)), Point((2, 1)), Point((0, 1))])
>>> c.bounding_box.left
0.0
>>> c.bounding_box.lower
0.0
>>> c.bounding_box.right
2.0
>>> c.bounding_box.upper
1.0
property len

Returns the geometric length of the chain.

Examples

>>> c = Chain([Point((0, 0)), Point((1, 0)), Point((1, 1)), Point((2, 1))])
>>> c.len
3.0
>>> c = Chain(
...     [
...         [Point((0, 0)), Point((1, 0)), Point((1, 1))],
...         [Point((10, 10)), Point((11, 10)), Point((11, 11))]
...     ]
... )
>>> c.len
4.0
property parts

Returns the parts (lists of libpysal.cg.Point objects) of the chain.

Examples

>>> c = Chain(
...     [
...         [Point((0, 0)), Point((1, 0)), Point((1, 1)), Point((0, 1))],
...         [Point((2, 1)), Point((2, 2)), Point((1, 2)), Point((1, 1))]
...     ]
... )
>>> len(c.parts)
2
property segments

Returns the segments that compose the chain.

property vertices

Returns the vertices of the chain in clockwise order.

Examples

>>> c = Chain([Point((0, 0)), Point((1, 0)), Point((1, 1)), Point((2, 1))])
>>> verts = c.vertices
>>> len(verts)
4