libpysal.cg.Polygon

class libpysal.cg.Polygon(vertices, holes=None)[source]

Geometric representation of polygon objects.

Attributes
verticeslist

Returns the vertices of the polygon in clockwise order.

lenint

Returns the number of vertices in the polygon.

perimeterfloat

Returns the perimeter of the polygon.

bounding_boxRectangle

Returns the bounding box of the polygon.

bboxList

Returns the bounding box of the polygon as a list

areafloat

Returns the area of the polygon.

centroidtuple

Returns the centroid of the polygon

Methods

build_quad_tree_structure(self)

Build the quad tree structure for this polygon.

contains_point(self, point)

Test if polygon contains point

__init__(self, vertices, holes=None)[source]

Returns a polygon created from the objects specified.

__init__(Point list or list of Point lists, holes list ) -> Polygon

Parameters
verticeslist – a list of vertices or a list of lists of vertices.
holeslist – a list of sub-polygons to be considered as holes.
is_quad_tree_structure_built

: bool – record if the quad tree structure has been built for this polygon. This quad tree structure could help speed up the contains_point test

Examples

>>> p1 = Polygon([Point((0, 0)), Point((1, 0)), Point((1, 1)), Point((0, 1))])

Methods

__init__(self, vertices[, holes])

Returns a polygon created from the objects specified.

build_quad_tree_structure(self)

Build the quad tree structure for this polygon.

contains_point(self, point)

Test if polygon contains point

Attributes

area

Returns the area of the polygon.

bbox

Returns the bounding box of the polygon as a list

bounding_box

Returns the bounding box of the polygon.

centroid

Returns the centroid of the polygon

holes

Returns the holes of the polygon in clockwise order.

len

Returns the number of vertices in the polygon.

parts

Returns the parts of the polygon in clockwise order.

perimeter

Returns the perimeter of the polygon.

vertices

Returns the vertices of the polygon in clockwise order.