Subgroup: other
Class: QgsRectangle¶
-
class
qgis.core.
QgsRectangle
¶ Bases:
sip.wrapper
A rectangle specified with double values.
QgsRectangle is used to store a rectangle when double values are required. Examples are storing a layer extent or the current view extent of a map
See also
Methods
area
Returns the area of the rectangle. asPolygon
Returns the rectangle as a polygon. asWktCoordinates
Returns a string representation of the rectangle in WKT format. asWktPolygon
Returns a string representation of the rectangle as a WKT Polygon. buffered
Get rectangle enlarged by buffer. center
Returns the center point of the rectangle. combineExtentWith
Expand the rectangle so that covers both the original rectangle and the given rectangle. contains
Return true when rectangle contains other rectangle. fromCenterAndSize
Creates a new rectangle, given the specified center
point andwidth
andheight
.fromWkt
Creates a new rectangle from a wkt
string.grow
Grows the rectangle in place by the specified amount. height
Returns the height of the rectangle. include
Updates the rectangle to include the specified point. intersect
Return the intersection with the given rectangle. intersects
Returns true when rectangle intersects with other rectangle. invert
Swap x/y coordinates in the rectangle. isEmpty
Returns true if the rectangle is empty. isFinite
Returns true if the rectangle has finite boundaries. isNull
Test if the rectangle is null (all coordinates zero or after call to setMinimal()). normalize
Normalize the rectangle so it has non-negative width/height. perimeter
Returns the perimeter of the rectangle. scale
Scale the rectangle around its center point. set
Sets the rectangle from two QgsPoints
.setMinimal
Set a rectangle so that min corner is at max and max corner is at min. setXMaximum
Set the maximum x value. setXMinimum
Set the minimum x value. setYMaximum
Set the maximum y value. setYMinimum
Set the minimum y value. toBox3d
Converts the rectangle to a 3D box, with the specified zMin
andzMax
z values.toRectF
Returns a QRectF with same coordinates as the rectangle. toString
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the specified precision. width
Returns the width of the rectangle. xMaximum
Returns the x maximum value (right side of rectangle). xMinimum
Returns the x minimum value (left side of rectangle). yMaximum
Returns the y maximum value (top side of rectangle). yMinimum
Returns the y minimum value (bottom side of rectangle). Attributes
-
area
(self) → float¶ Returns the area of the rectangle.
New in version 3.0.
See also
See also
See also
-
asPolygon
(self) → str¶ Returns the rectangle as a polygon.
-
asWktCoordinates
(self) → str¶ Returns a string representation of the rectangle in WKT format.
-
asWktPolygon
(self) → str¶ Returns a string representation of the rectangle as a WKT Polygon.
-
buffered
(self, width: float) → QgsRectangle¶ Get rectangle enlarged by buffer.
Note
In earlier QGIS releases this method was named buffer().
New in version 3.0.
See also
-
center
(self) → QgsPointXY¶ Returns the center point of the rectangle.
-
combineExtentWith
(self, rect: QgsRectangle)¶ Expand the rectangle so that covers both the original rectangle and the given rectangle.
combineExtentWith(self, x: float, y: float) Expand the rectangle so that covers both the original rectangle and the given point.
-
contains
(self, rect: QgsRectangle) → bool¶ Return true when rectangle contains other rectangle.
contains(self, p: QgsPointXY) -> bool Return true when rectangle contains a point.
-
fromCenterAndSize
(center: QgsPointXY, width: float, height: float) → QgsRectangle¶ Creates a new rectangle, given the specified
center
point andwidth
andheight
.New in version 3.0.
-
fromWkt
(wkt: str) → QgsRectangle¶ Creates a new rectangle from a
wkt
string. The WKT must contain only 5 vertices, representing a rectangle aligned with X and Y axes.New in version 3.0.
-
grow
(self, delta: float)¶ Grows the rectangle in place by the specified amount.
See also
-
include
(self, p: QgsPointXY)¶ Updates the rectangle to include the specified point.
-
intersect
(self, rect: QgsRectangle) → QgsRectangle¶ Return the intersection with the given rectangle.
-
intersects
(self, rect: QgsRectangle) → bool¶ Returns true when rectangle intersects with other rectangle.
-
invert
(self)¶ Swap x/y coordinates in the rectangle.
-
isEmpty
(self) → bool¶ Returns true if the rectangle is empty. An empty rectangle may still be non-null if it contains valid information (e.g. bounding box of a point).
-
isFinite
(self) → bool¶ Returns true if the rectangle has finite boundaries. Will return false if any of the rectangle boundaries are NaN or Inf.
-
isNull
(self) → bool¶ Test if the rectangle is null (all coordinates zero or after call to setMinimal()). A null rectangle is also an empty rectangle.
New in version 2.4.
-
normalize
(self)¶ Normalize the rectangle so it has non-negative width/height.
-
perimeter
(self) → float¶ Returns the perimeter of the rectangle.
New in version 3.0.
See also
-
scale
(self, scaleFactor: float, c: QgsPointXY = None)¶ Scale the rectangle around its center point.
scale(self, scaleFactor: float, centerX: float, centerY: float) Scale the rectangle around its center point.
-
set
(self, p1: QgsPointXY, p2: QgsPointXY)¶ Sets the rectangle from two
QgsPoints
. The rectangle is normalised after construction.set(self, mXmin: float, mYmin: float, mXmax: float, mYmax: float) Sets the rectangle from four points. The rectangle is normalised after construction.
-
setMinimal
(self)¶ Set a rectangle so that min corner is at max and max corner is at min. It is NOT normalized.
-
setXMaximum
(self, x: float)¶ Set the maximum x value.
-
setXMinimum
(self, x: float)¶ Set the minimum x value.
-
setYMaximum
(self, y: float)¶ Set the maximum y value.
-
setYMinimum
(self, y: float)¶ Set the minimum y value.
-
toBox3d
(self, zMin: float, zMax: float) → QgsBox3d¶ Converts the rectangle to a 3D box, with the specified
zMin
andzMax
z values.New in version 3.0.
-
toRectF
(self) → QRectF¶ Returns a QRectF with same coordinates as the rectangle.
-
toString
(self, precision: int = 16) → str¶ Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the specified precision. If the specified precision is less than 0, a suitable minimum precision is used.
-
xMaximum
(self) → float¶ Returns the x maximum value (right side of rectangle).
-
xMinimum
(self) → float¶ Returns the x minimum value (left side of rectangle).
-
yMaximum
(self) → float¶ Returns the y maximum value (top side of rectangle).
-
yMinimum
(self) → float¶ Returns the y minimum value (bottom side of rectangle).
-