libpysal.cg.Rectangle¶
-
class
libpysal.cg.Rectangle(left, lower, right, upper)[source]¶ Geometric representation of rectangle objects.
- Attributes
- left
python:float Minimum x-value of the rectangle
- lower
python:float Minimum y-value of the rectangle
- right
python:float Maximum x-value of the rectangle
- upper
python:float Maximum y-value of the rectangle
- left
-
__init__(self, left, lower, right, upper)[source]¶ Returns a Rectangle object.
__init__(number, number, number, number) -> Rectangle
- Parameters
- left
theminimumx-valueoftherectangle - lower
theminimumy-valueoftherectangle - right
themaximumx-valueoftherectangle - upper
themaximumy-valueoftherectangle
- left
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
Methods
__init__(self, left, lower, right, upper)Returns a Rectangle object.
set_centroid(self, new_center)Moves the rectangle center to a new specified point.
set_scale(self, scale)Rescales the rectangle around its center.
Attributes
Returns the area of the Rectangle.
Returns the height of the Rectangle.
Returns the width of the Rectangle.
-
property
area¶ Returns the area of the Rectangle.
area -> number
Examples
>>> r = Rectangle(0, 0, 4, 4) >>> r.area 16.0
-
property
height¶ Returns the height of the Rectangle.
height -> number
Examples
>>> r = Rectangle(0, 0, 4, 4) >>> r.height 4.0
-
set_centroid(self, new_center)[source]¶ Moves the rectangle center to a new specified point.
set_centroid(Point) -> Point
- Parameters
- new_center
thenewlocationofthecentroidofthepolygon
- new_center
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(self, scale)[source]¶ Rescales the rectangle around its center.
set_scale(number) -> number
- Parameters
- scale
theratioofthenewscaletotheoldscale(e.g. 1.0iscurrentsize)
- scale
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¶ Returns the width of the Rectangle.
width -> number
Examples
>>> r = Rectangle(0, 0, 4, 4) >>> r.width 4.0