Class: QgsCurvePolygon¶
- class qgis.core.QgsCurvePolygon¶
Bases:
QgsSurface
Curve polygon geometry type
New in version 2.10:
Methods
Adds an interior ring to the geometry (takes ownership)
- param mValue:
- param zValue:
- param vertex:
- rtype:
float
- param doc:
- param doc:
- param precision:
- rtype:
QPainterPath
- param flags:
- param precision:
- rtype:
QgsAbstractGeometry
- param rectangle:
- rtype:
QgsRectangle
- rtype:
int
- param index:
Returns point at index (for geometries without child geometries - i.e. curve / point).
- rtype:
QgsCurvePolygon
- param pt:
- param other:
- rtype:
object
- rtype:
QgsCurvePolygon
- param position:
- rtype:
int
- param p:
- rtype:
bool
- rtype:
bool
Returns the curve polygon's exterior ring.
Forces the polygon to respect the exterior ring is clockwise, interior rings are counter-clockwise convention.
Forces the polygon to respect the exterior ring is counter-clockwise, interior rings are clockwise convention.
Forces the geometry to respect the Right-Hand-Rule, in which the area that is bounded by the polygon is to the right of the boundary.
- param wkb:
- param wkt:
- rtype:
str
Returns whether the geometry has any child geometries (
False
for point / curve,True
otherwise)- rtype:
bool
- param position:
Retrieves an interior ring from the curve polygon.
- rtype:
bool
- param position:
- rtype:
int
- param id:
Returns the number of interior rings contained with the curve polygon.
- rtype:
int
- rtype:
float
- param epsilon:
Removes an interior ring from the polygon.
Removes the interior rings from the polygon.
Removes any interior rings which are not valid from the polygon.
- param part:
Returns the roundness of the curve polygon.
- param startVertex:
Returns a geometry without curves.
Sets the exterior ring of the polygon.
Sets all interior rings (takes ownership)
Updates the geometry type based on whether sub geometries contain z or m values.
- param hSpacing:
Returns the sort index for the geometry, used in the
compareTo()
method to compare geometries of different types.- rtype:
QgsPolygon
- rtype:
QgsCurvePolygon
Returns a new polygon geometry corresponding to a segmentized approximation of the curve.
- param ct:
Returns approximate rotation angle for a vertex.
- param id:
- param part:
- param id:
- param flags:
- addInteriorRing(self, ring: QgsCurve)¶
Adds an interior ring to the geometry (takes ownership)
- Parameters:
ring (QgsCurve) –
- addMValue(self, mValue: float = 0) bool ¶
- Parameters:
mValue (float = 0) –
- Return type:
bool
- addZValue(self, zValue: float = 0) bool ¶
- Parameters:
zValue (float = 0) –
- Return type:
bool
- adjacentVertices(self, vertex: QgsVertexId) Tuple[QgsVertexId, QgsVertexId] ¶
- Parameters:
vertex (QgsVertexId) –
- Return type:
Tuple[
QgsVertexId
, QgsVertexId]
- area(self) float ¶
- Return type:
float
- asGml2(self, doc: QDomDocument, precision: int = 17, ns: str = '', axisOrder: QgsAbstractGeometry.AxisOrder = QgsAbstractGeometry.AxisOrder.XY) QDomElement ¶
- Parameters:
doc (QDomDocument) –
precision (int = 17) –
ns (str = '') –
axisOrder (QgsAbstractGeometry.AxisOrder = QgsAbstractGeometry.AxisOrder.XY) –
- Return type:
QDomElement
- asGml3(self, doc: QDomDocument, precision: int = 17, ns: str = '', axisOrder: QgsAbstractGeometry.AxisOrder = QgsAbstractGeometry.AxisOrder.XY) QDomElement ¶
- Parameters:
doc (QDomDocument) –
precision (int = 17) –
ns (str = '') –
axisOrder (QgsAbstractGeometry.AxisOrder = QgsAbstractGeometry.AxisOrder.XY) –
- Return type:
QDomElement
- asKml(self, precision: int = 17) str ¶
- Parameters:
precision (int = 17) –
- Return type:
str
- asQPainterPath(self) QPainterPath ¶
- Return type:
QPainterPath
- asWkb(self, flags: QgsAbstractGeometry.WkbFlags | QgsAbstractGeometry.WkbFlag = QgsAbstractGeometry.WkbFlags()) QByteArray ¶
- Parameters:
flags (Union[QgsAbstractGeometry.WkbFlags) –
- Return type:
QByteArray
- asWkt(self, precision: int = 17) str ¶
- Parameters:
precision (int = 17) –
- Return type:
str
- boundary(self) QgsAbstractGeometry ¶
- Return type:
- boundingBoxIntersects(self, rectangle: QgsRectangle) bool ¶
- Parameters:
rectangle (QgsRectangle) –
- Return type:
bool
- calculateBoundingBox(self) QgsRectangle ¶
- Return type:
- childCount(self) int ¶
- Return type:
int
- childGeometry(self, index: int) QgsAbstractGeometry ¶
- Parameters:
index (int) –
- Return type:
- childPoint(self, index: int) QgsPoint ¶
Returns point at index (for geometries without child geometries - i.e. curve / point)
Note
used for vertex_iterator implementation
New in version 3.0.
- clear(self)¶
- clearCache(self)¶
- clone(self) QgsCurvePolygon ¶
- Return type:
- closestSegment(self, pt: QgsPoint, epsilon: float = 4 * DBL_EPSILON) Tuple[float, QgsPoint, QgsVertexId, int] ¶
- Parameters:
pt (QgsPoint) –
epsilon (float = 4*DBL_EPSILON) –
- Return type:
Tuple[float,
QgsPoint
,QgsVertexId
, int]
- compareToSameClass(self, other: QgsAbstractGeometry) int ¶
- Parameters:
other (QgsAbstractGeometry) –
- Return type:
int
- coordinateSequence(self) object ¶
- Return type:
object
- createEmptyWithSameType(self) QgsCurvePolygon ¶
- Return type:
- deleteVertex(self, position: QgsVertexId) bool ¶
- Parameters:
position (QgsVertexId) –
- Return type:
bool
- dimension(self) int ¶
- Return type:
int
- draw(self, p: QPainter)¶
- Parameters:
p (QPainter) –
- dropMValue(self) bool ¶
- Return type:
bool
- dropZValue(self) bool ¶
- Return type:
bool
- forceClockwise(self)¶
Forces the polygon to respect the exterior ring is clockwise, interior rings are counter-clockwise convention.
This convention is used primarily by ESRI software.
See also
New in version 3.24.
- forceCounterClockwise(self)¶
Forces the polygon to respect the exterior ring is counter-clockwise, interior rings are clockwise convention.
This convention matches the OGC Simple Features specification.
See also
New in version 3.24.
- forceRHR(self)¶
Forces the geometry to respect the Right-Hand-Rule, in which the area that is bounded by the polygon is to the right of the boundary. In particular, the exterior ring is oriented in a clockwise direction and the interior rings in a counter-clockwise direction.
Warning
Due to the conflicting definitions of the right-hand-rule in general use, it is recommended to use the explicit
forceClockwise()
orforceCounterClockwise()
methods instead.See also
See also
New in version 3.6.
- fromWkb(self, wkb: QgsConstWkbPtr) bool ¶
- Parameters:
wkb (QgsConstWkbPtr) –
- Return type:
bool
- fromWkt(self, wkt: str) bool ¶
- Parameters:
wkt (str) –
- Return type:
bool
- geometryType(self) str ¶
- Return type:
str
- hasChildGeometries(self) bool ¶
Returns whether the geometry has any child geometries (
False
for point / curve,True
otherwise)Note
used for vertex_iterator implementation
New in version 3.0.
- hasCurvedSegments(self) bool ¶
- Return type:
bool
- insertVertex(self, position: QgsVertexId, vertex: QgsPoint) bool ¶
- Parameters:
position (QgsVertexId) –
vertex (QgsPoint) –
- Return type:
bool
- interiorRing(self, i: int) QgsCurve ¶
Retrieves an interior ring from the curve polygon. The first interior ring has index 0.
- Raises:
IndexError – if no interior ring with the specified index exists.
See also
See also
- Parameters:
i (int) –
- Return type:
- isEmpty(self) bool ¶
- Return type:
bool
- moveVertex(self, position: QgsVertexId, newPos: QgsPoint) bool ¶
- Parameters:
position (QgsVertexId) –
newPos (QgsPoint) –
- Return type:
bool
- nCoordinates(self) int ¶
- Return type:
int
- nextVertex(self, id: QgsVertexId) Tuple[bool, QgsPoint] ¶
- Parameters:
id (QgsVertexId) –
- Return type:
Tuple[bool, QgsPoint]
- normalize(self)¶
- numInteriorRings(self) int ¶
Returns the number of interior rings contained with the curve polygon.
See also
- Return type:
int
- partCount(self) int ¶
- Return type:
int
- perimeter(self) float ¶
- Return type:
float
- removeDuplicateNodes(self, epsilon: float = 4 * DBL_EPSILON, useZValues: bool = False) bool ¶
- Parameters:
epsilon (float = 4*DBL_EPSILON) –
useZValues (bool = False) –
- Return type:
bool
- removeInteriorRing(self, i: int) bool ¶
Removes an interior ring from the polygon. The first interior ring has index 0. The corresponding ring is removed from the polygon and deleted. It is not possible to remove the exterior ring using this method.
- Raises:
IndexError – if no interior ring with the specified index exists.
See also
- Parameters:
i (int) –
- Return type:
bool
- removeInteriorRings(self, minimumAllowedArea: float = -1)¶
Removes the interior rings from the polygon. If the minimumAllowedArea parameter is specified then only rings smaller than this minimum area will be removed.
See also
New in version 3.0.
- Parameters:
minimumAllowedArea (float = -1) –
- removeInvalidRings(self)¶
Removes any interior rings which are not valid from the polygon.
For example, this removes unclosed rings and rings with less than 4 vertices.
New in version 3.0.
- ringCount(self, part: int = 0) int ¶
- Parameters:
part (int = 0) –
- Return type:
int
- roundness(self) float ¶
Returns the roundness of the curve polygon. The returned value is between 0 and 1.
New in version 3.24.
- Return type:
float
- segmentLength(self, startVertex: QgsVertexId) float ¶
- Parameters:
startVertex (QgsVertexId) –
- Return type:
float
- segmentize(self, tolerance: float = M_PI_2 / 90, toleranceType: QgsAbstractGeometry.SegmentationToleranceType = QgsAbstractGeometry.MaximumAngle) QgsAbstractGeometry ¶
Returns a geometry without curves. Caller takes ownership
- Parameters:
tolerance (float = M_PI_2/90) – segmentation tolerance
toleranceType (QgsAbstractGeometry.SegmentationToleranceType = QgsAbstractGeometry.MaximumAngle) – maximum segmentation angle or maximum difference between approximation and curve
- Return type:
- setExteriorRing(self, ring: QgsCurve)¶
Sets the exterior ring of the polygon. The CurvePolygon type will be updated to match the dimensionality of the exterior ring. For instance, setting a 2D exterior ring on a 3D CurvePolygon will drop the z dimension from the CurvePolygon and all interior rings.
- Parameters:
ring (QgsCurve) – new exterior ring. Ownership is transferred to the CurvePolygon.
See also
See also
- setInteriorRings(self, rings: Iterable[QgsCurve])¶
Sets all interior rings (takes ownership)
- Parameters:
rings (Iterable[QgsCurve]) –
- setZMTypeFromSubGeometry(self, subggeom: QgsAbstractGeometry, baseGeomType: QgsWkbTypes.Type)¶
Updates the geometry type based on whether sub geometries contain z or m values.
- snappedToGrid(self, hSpacing: float, vSpacing: float, dSpacing: float = 0, mSpacing: float = 0) QgsCurvePolygon ¶
- Parameters:
hSpacing (float) –
vSpacing (float) –
dSpacing (float = 0) –
mSpacing (float = 0) –
- Return type:
- sortIndex(self) int ¶
Returns the sort index for the geometry, used in the
compareTo()
method to compare geometries of different types.New in version 3.20.
- surfaceToPolygon(self) QgsPolygon ¶
- Return type:
- swapXy(self)¶
- toCurveType(self) QgsCurvePolygon ¶
- Return type:
- toPolygon(self, tolerance: float = M_PI_2 / 90, toleranceType: QgsAbstractGeometry.SegmentationToleranceType = QgsAbstractGeometry.MaximumAngle) QgsPolygon ¶
Returns a new polygon geometry corresponding to a segmentized approximation of the curve.
- Parameters:
tolerance (float = M_PI_2/90) – segmentation tolerance
toleranceType (QgsAbstractGeometry.SegmentationToleranceType = QgsAbstractGeometry.MaximumAngle) – maximum segmentation angle or maximum difference between approximation and curve
- Return type:
- transform(self, ct: QgsCoordinateTransform, d: Qgis.TransformDirection = Qgis.TransformDirection.Forward, transformZ: bool = False)¶
- transform(self, t: QTransform, zTranslate: float = 0, zScale: float = 1, mTranslate: float = 0, mScale: float = 1) None
- transform(self, transformer: QgsAbstractGeometryTransformer, feedback: QgsFeedback = None) bool
- Parameters:
ct (QgsCoordinateTransform) –
d (Qgis.TransformDirection = Qgis.TransformDirection.Forward) –
transformZ (bool = False) –
- vertexAngle(self, vertex: QgsVertexId) float ¶
Returns approximate rotation angle for a vertex. Usually average angle between adjacent segments.
- Parameters:
vertex (QgsVertexId) – the vertex id
- Return type:
float
- Returns:
rotation in radians, clockwise from north
- vertexAt(self, id: QgsVertexId) QgsPoint ¶
- Parameters:
id (QgsVertexId) –
- Return type:
- vertexCount(self, part: int = 0, ring: int = 0) int ¶
- Parameters:
part (int = 0) –
ring (int = 0) –
- Return type:
int
- vertexNumberFromVertexId(self, id: QgsVertexId) int ¶
- Parameters:
id (QgsVertexId) –
- Return type:
int
- wkbSize(self, flags: QgsAbstractGeometry.WkbFlags | QgsAbstractGeometry.WkbFlag = QgsAbstractGeometry.WkbFlags()) int ¶
- Parameters:
flags (Union[QgsAbstractGeometry.WkbFlags) –
- Return type:
int