libpysal.cg.Rectangle

class libpysal.cg.Rectangle(left, lower, right, upper)[source]

Geometric representation of rectangle objects.

Attributes:
leftfloat

Minimum x-value of the rectangle.

lowerfloat

Minimum y-value of the rectangle.

rightfloat

Maximum x-value of the rectangle.

upperfloat

Maximum y-value of the rectangle.

Examples

>>> r = Rectangle(-4, 3, 10, 17)
>>> r.left #minx
-4.0
>>> r.lower #miny
3.0
>>> r.right #maxx
10.0
>>> r.upper #maxy
17.0
__init__(left, lower, right, upper)[source]

Methods

__init__(left, lower, right, upper)

set_centroid(new_center)

Moves the rectangle center to a new specified point.

set_scale(scale)

Rescales the rectangle around its center.

Attributes

area

Returns the area of the Rectangle.

height

Returns the height of the Rectangle.

width

Returns the width of the Rectangle.

property area: int | float

Returns the area of the Rectangle.

Examples

>>> r = Rectangle(0, 0, 4, 4)
>>> r.area
16.0
property height: int | float

Returns the height of the Rectangle.

Examples

>>> r = Rectangle(0, 0, 4, 4)
>>> r.height
4.0
set_centroid(new_center)[source]

Moves the rectangle center to a new specified point.

Parameters:
new_centerlibpysal.cg.Point

The new location of the centroid of the polygon.

Examples

>>> r = Rectangle(0, 0, 4, 4)
>>> r.set_centroid(Point((4, 4)))
>>> r.left
2.0
>>> r.right
6.0
>>> r.lower
2.0
>>> r.upper
6.0
set_scale(scale)[source]

Rescales the rectangle around its center.

Parameters:
scaleint, float

The ratio of the new scale to the old scale (e.g. 1.0 is current size).

Examples

>>> r = Rectangle(0, 0, 4, 4)
>>> r.set_scale(2)
>>> r.left
-2.0
>>> r.right
6.0
>>> r.lower
-2.0
>>> r.upper
6.0
property width: int | float

Returns the width of the Rectangle.

Examples

>>> r = Rectangle(0, 0, 4, 4)
>>> r.width
4.0