Class: QgsFeatureRequest¶
- class qgis.core.QgsFeatureRequest¶
Bases:
sip.wrapper
This class wraps a request for features to a vector layer (or directly its vector data provider).
The request may apply an attribute/ID filter to fetch only a particular subset of features. Currently supported filters:
no filter - all features are returned
feature id - only feature that matches given feature id is returned
feature ids - only features that match any of the given feature ids are returned
filter expression - only features that match the given filter expression are returned
Additionally a spatial filter can be set in combination with the attribute/ID filter. Supported spatial filters are:
Qgis.SpatialFilterType.BoundingBox: Only features that intersect a given rectangle will be fetched. For the sake of speed, the intersection is often done only using feature’s bounding box. There is a flag ExactIntersect that makes sure that only intersecting features will be returned.
Qgis.SpatialFilterType.DistanceWithin: Only features within a specified distance of a reference geometry will be fetched.
For efficiency, it is also possible to tell provider that some data is not required:
NoGeometry flag
SubsetOfAttributes flag
SimplifyMethod for geometries to fetch
The options may be chained, e.g.:
QgsFeatureRequest().setFilterRect(QgsRectangle(0,0,1,1)).setFlags(QgsFeatureRequest.ExactIntersect)
Examples:
# fetch all features: QgsFeatureRequest() # fetch all features, only one attribute QgsFeatureRequest().setSubsetOfAttributes(['myfield'], layer.fields()) # fetch all features, without geometries QgsFeatureRequest().setFlags(QgsFeatureRequest.NoGeometry) # fetch only features from particular extent QgsFeatureRequest().setFilterRect(QgsRectangle(0,0,1,1)) # fetch only features from particular extent, where the 'type' attribute is equal to 'road': QgsFeatureRequest().setFilterRect(QgsRectangle(0,0,1,1)).setFilterExpression('"type"=\'road\'') # fetch only one feature QgsFeatureRequest().setFilterFid(45) # fetch features within 50 map units of a linestring geometry QgsFeatureRequest().setDistanceWithin(QgsGeometry.fromWkt('LineString(0 0, 10 0, 12 1)'), 50)
QgsFeatureRequest() construct a default request: for all features get attributes and geometries
QgsFeatureRequest(fid: int) construct a request with feature ID filter
QgsFeatureRequest(fids: object) construct a request with feature ID filter
QgsFeatureRequest(rectangle:
QgsRectangle
) Construct a request withrectangle
bounding box filter.When a destination CRS is set using
setDestinationCrs()
,rectangle
is expected to be in the same CRS as thedestinationCrs()
. Otherwise,rectangle
should use the same CRS as the source layer/provider.QgsFeatureRequest(expr:
QgsExpression
, context:QgsExpressionContext
= QgsExpressionContext()) construct a request with a filter expressionQgsFeatureRequest(rh:
QgsFeatureRequest
) copy constructorMethods
Check if a feature is accepted by this requests filter
Adds a new OrderByClause, appending it as the least important one.
Modifies the existing filter expression to add an additional expression filter.
Returns the timeout (in milliseconds) for how long we should wait for a connection if none is available from the pool at this moment.
Returns the destination coordinate reference system for feature's geometries, or an invalid
QgsCoordinateReferenceSystem
if no reprojection will be done and all features will be left with their original geometry.Disables any attribute/ID filtering.
Returns the maximum distance from the
referenceGeometry()
of fetched features, ifspatialFilterType()
is Qgis.SpatialFilterType.DistanceWithin.Returns the expression context used to evaluate filter expressions.
Returns the feedback object that can be queried regularly by the iterator to check if it should be canceled, if set.
Returns the filter expression (if set).
Returns the feature ID that should be fetched.
Returns the feature IDs that should be fetched.
Returns the rectangle from which features will be taken.
Returns the attribute/ID filter type which is currently set on this request.
Returns the flags which affect how features are fetched.
Returns the invalid geometry checking behavior.
Returns the maximum number of features to request, or -1 if no limit set.
Returns a list of order by clauses specified for this feature request.
Returns the reference geometry used for spatial filtering of features.
In case this request may be run nested within another already running iteration on the same connection, set this to
True
.Sets the timeout (in milliseconds) for how long we should wait for a connection if none is available from the pool at this moment.
Sets the destination
crs
for feature's geometries.Sets a reference
geometry
and a maximumdistance
from this geometry to retrieve features within.Sets the expression context used to evaluate filter expressions.
Attach a
feedback
object that can be queried regularly by the iterator to check if it should be canceled.Set the filter
expression
.Sets the feature ID that should be fetched.
Sets the feature IDs that should be fetched.
Sets the
rectangle
from which features will be taken.Sets
flags
that affect how features will be fetched.Sets a callback function to use when encountering an invalid geometry and
invalidGeometryCheck()
is set to GeometryAbortOnInvalid or GeometrySkipInvalid.Sets invalid geometry checking behavior.
Set the maximum number of features to request.
Set that no attributes will be fetched.
Set a list of order by clauses.
In case this request may be run nested within another already running iteration on the same connection, set this to
True
.Set a simplification method for geometries that will be fetched.
Set a subset of attributes that will be fetched.
Sets the
timeout
(in milliseconds) for the maximum time we should wait during feature requests before a feature is returned.Sets a callback function to use when encountering a transform error when iterating features and a
destinationCrs()
is set.Returns the simplification method for geometries that will be fetched.
Returns the spatial filter type which is currently set on this request.
Returns the subset of attributes which at least need to be fetched.
Returns the timeout (in milliseconds) for the maximum time we should wait during feature requests before a feature is returned.
Returns the transform context, for use when a
destinationCrs()
has been set and reprojection is requiredAttributes
- ALL_ATTRIBUTES = '#!allattributes!#'¶
- EmbeddedSymbols = 16¶
- ExactIntersect = 4¶
- FilterExpression = 2¶
- FilterFid = 1¶
- FilterFids = 3¶
- FilterNone = 0¶
- class FilterType¶
Bases:
int
- class Flag¶
Bases:
int
- class Flags¶
- class Flags(Union[QgsFeatureRequest.Flags, QgsFeatureRequest.Flag])
- class Flags(QgsFeatureRequest.Flags)
Bases:
sip.wrapper
- GeometryAbortOnInvalid = 2¶
- GeometryNoCheck = 0¶
- GeometrySkipInvalid = 1¶
- IgnoreStaticNodesDuringExpressionCompilation = 8¶
- class InvalidGeometryCheck¶
Bases:
int
- NoFlags = 0¶
- NoGeometry = 1¶
- class OrderBy¶
Bases:
sip.wrapper
Represents a list of OrderByClauses, with the most important first and the least important last.
New in version 2.14.
QgsFeatureRequest.OrderBy() Create a new empty order by
QgsFeatureRequest.OrderBy(other: Iterable[QgsFeatureRequest.OrderByClause]) Create a new order by from a list of clauses
QgsFeatureRequest.OrderBy(QgsFeatureRequest.OrderBy)
- dump(self) str ¶
Dumps the content to an SQL equivalent syntax
- Return type:
str
- list(self) List[QgsFeatureRequest.OrderByClause] ¶
Gets a copy as a list of OrderByClauses
This is only required in Python where the inheritance is not properly propagated and this makes it usable.
- Return type:
- load(self, elem: QDomElement)¶
Deserialize from XML
- Parameters:
elem (QDomElement) –
- save(self, elem: QDomElement)¶
Serialize to XML
- Parameters:
elem (QDomElement) –
- usedAttributeIndices(self, fields: QgsFields) object ¶
Returns a set of used, validated attribute indices
New in version 3.8.
- Parameters:
fields (QgsFields) –
- Return type:
object
- usedAttributes(self) Set[str] ¶
Returns a set of used attributes
Note
The returned attributes names are NOT guaranteed to be valid.
- Return type:
Set[str]
- class OrderByClause¶
Bases:
sip.wrapper
The OrderByClause class represents an order by clause for a QgsFeatureRequest.
It can be a simple field or an expression. Multiple order by clauses can be added to a
QgsFeatureRequest
to fine tune the behavior if a single field or expression is not enough to completely specify the required behavior.If expression compilation is activated in the settings and the expression can be translated for the provider in question, it will be evaluated on provider side. If one of these two premises does not apply, the ordering will take place locally which results in increased memory and CPU usage.
If the ordering is done on strings, the order depends on the system’s locale if the local fallback implementation is used. The order depends on the server system’s locale and implementation if ordering is done on the server.
In case the fallback code needs to be used, a limit set on the request will be respected for the features returned by the iterator but internally all features will be requested from the provider.
New in version 2.14.
QgsFeatureRequest.OrderByClause(expression: str, ascending: bool = True) Creates a new OrderByClause for a
QgsFeatureRequest
- Parameters:
expression – The expression to use for ordering
ascending – If the order should be ascending (1,2,3) or descending (3,2,1) If the order is ascending, by default nulls are last If the order is descending, by default nulls are first
QgsFeatureRequest.OrderByClause(expression: str, ascending: bool, nullsfirst: bool) Creates a new OrderByClause for a
QgsFeatureRequest
- Parameters:
expression – The expression to use for ordering
ascending – If the order should be ascending (1,2,3) or descending (3,2,1)
nullsfirst – If
True
, NULLS are at the beginning, ifFalse
, NULLS are at the end
QgsFeatureRequest.OrderByClause(expression:
QgsExpression
, ascending: bool = True) Creates a new OrderByClause for aQgsFeatureRequest
- Parameters:
expression – The expression to use for ordering
ascending – If the order should be ascending (1,2,3) or descending (3,2,1) If the order is ascending, by default nulls are last If the order is descending, by default nulls are first
QgsFeatureRequest.OrderByClause(expression:
QgsExpression
, ascending: bool, nullsfirst: bool) Creates a new OrderByClause for aQgsFeatureRequest
- Parameters:
expression – The expression to use for ordering
ascending – If the order should be ascending (1,2,3) or descending (3,2,1)
nullsfirst – If
True
, NULLS are at the beginning, ifFalse
, NULLS are at the end
QgsFeatureRequest.OrderByClause(QgsFeatureRequest.OrderByClause)
- ascending(self) bool ¶
Order ascending
- Return type:
bool
- Returns:
If ascending order is requested
- dump(self) str ¶
Dumps the content to an SQL equivalent
- Return type:
str
- expression(self) QgsExpression ¶
The expression
- Return type:
- Returns:
the expression
- nullsFirst(self) bool ¶
Set if NULLS should be returned first
- Return type:
bool
- Returns:
if NULLS should be returned first
- prepare(self, context: QgsExpressionContext) bool ¶
Prepare the expression with the given context.
See also
New in version 3.0.
- Parameters:
context (QgsExpressionContext) –
- Return type:
bool
- setAscending(self, ascending: bool)¶
Set if ascending order is requested
- Parameters:
ascending (bool) –
- setNullsFirst(self, nullsFirst: bool)¶
Set if NULLS should be returned first
- Parameters:
nullsFirst (bool) –
- SubsetOfAttributes = 2¶
- acceptFeature(self, feature: QgsFeature) bool ¶
Check if a feature is accepted by this requests filter
- Parameters:
feature (QgsFeature) – The feature which will be tested
- Return type:
bool
- Returns:
True
, if the filter accepts the feature
New in version 2.1.
- addOrderBy(self, expression: str, ascending: bool = True) QgsFeatureRequest ¶
Adds a new OrderByClause, appending it as the least important one.
- Parameters:
expression (str) – The expression to use for ordering
ascending (bool = True) – If the order should be ascending (1,2,3) or descending (3,2,1) If the order is ascending, by default nulls are last If the order is descending, by default nulls are first
New in version 2.14.
addOrderBy(self, expression: str, ascending: bool, nullsfirst: bool) -> QgsFeatureRequest Adds a new OrderByClause, appending it as the least important one.
- Parameters:
expression – The expression to use for ordering
ascending – If the order should be ascending (1,2,3) or descending (3,2,1)
nullsfirst – If
True
, NULLS are at the beginning, ifFalse
, NULLS are at the end
New in version 2.14.
- Return type:
- combineFilterExpression(self, expression: str) QgsFeatureRequest ¶
Modifies the existing filter expression to add an additional expression filter. The filter expressions are combined using AND, so only features matching both the existing expression and the additional expression will be returned.
Calling this method will automatically set
filterType()
to QgsFeatureRequest.FilterExpression.New in version 2.14.
- Parameters:
expression (str) –
- Return type:
- connectionTimeout(self) int ¶
Returns the timeout (in milliseconds) for how long we should wait for a connection if none is available from the pool at this moment. A negative value (which is set by default) will wait forever.
Note
Only works if the provider supports this option.
Deprecated since version Use:
timeout()
instead.New in version 3.0.
- Return type:
int
- destinationCrs(self) QgsCoordinateReferenceSystem ¶
Returns the destination coordinate reference system for feature’s geometries, or an invalid
QgsCoordinateReferenceSystem
if no reprojection will be done and all features will be left with their original geometry.See also
See also
New in version 3.0.
- Return type:
- disableFilter(self) QgsFeatureRequest ¶
Disables any attribute/ID filtering.
Calling this method will automatically set
filterType()
to QgsFeatureRequest.FilterNone.Note
Spatial filters will be left in place.
- Return type:
- Returns:
The object the method is called on for chaining
New in version 2.12.
- distanceWithin(self) float ¶
Returns the maximum distance from the
referenceGeometry()
of fetched features, ifspatialFilterType()
is Qgis.SpatialFilterType.DistanceWithin.When a destination CRS is set using
setDestinationCrs()
, the distance will be in the spatial units ofdestinationCrs()
. Otherwise, the distance will use the same units as the CRS of the source layer/provider.See also
New in version 3.22.
- Return type:
float
- expressionContext(self) QgsExpressionContext ¶
Returns the expression context used to evaluate filter expressions.
See also
See also
New in version 2.12.
- Return type:
- feedback(self) QgsFeedback ¶
Returns the feedback object that can be queried regularly by the iterator to check if it should be canceled, if set.
See also
New in version 3.20.
- Return type:
- filterExpression(self) QgsExpression ¶
Returns the filter expression (if set).
See also
See also
- Return type:
- filterFid(self) int ¶
Returns the feature ID that should be fetched.
See also
See also
- Return type:
int
- filterFids(self) object ¶
Returns the feature IDs that should be fetched.
See also
See also
- Return type:
object
- filterRect(self) QgsRectangle ¶
Returns the rectangle from which features will be taken. If the returned rectangle is null, then no filter rectangle is set.
If
spatialFilterType()
is Qgis.SpatialFilterType.BoundingBox then only features from within this bounding box will be fetched. IfspatialFilterType()
is Qgis.SpatialFilterType.DistanceWithin then the returned rectangle represents the bounding box of thereferenceGeometry()
extended bydistanceWithin()
.When a destination CRS is set using
setDestinationCrs()
, the rectangle will be in the same CRS as thedestinationCrs()
. Otherwise, the rectangle will use the same CRS as the source layer/provider.See also
- Return type:
- filterType(self) QgsFeatureRequest.FilterType ¶
Returns the attribute/ID filter type which is currently set on this request.
This type will automatically be set to the appropriate value whenever
setFilterFid()
,setFilterFids()
,setFilterExpression()
ordisableFilter()
are called.Note
A feature request may have both an attribute/ID filter AND a spatial filter set. See
spatialFilterType()
to retrieve the spatial filter.See also
- Return type:
- flags(self) QgsFeatureRequest.Flags ¶
Returns the flags which affect how features are fetched.
See also
- Return type:
- invalidGeometryCheck(self) QgsFeatureRequest.InvalidGeometryCheck ¶
Returns the invalid geometry checking behavior.
See also
New in version 3.0.
- Return type:
- limit(self) int ¶
Returns the maximum number of features to request, or -1 if no limit set.
See also
New in version 2.14.
- Return type:
int
- orderBy(self) QgsFeatureRequest.OrderBy ¶
Returns a list of order by clauses specified for this feature request.
New in version 2.14.
- Return type:
- referenceGeometry(self) QgsGeometry ¶
Returns the reference geometry used for spatial filtering of features.
When
spatialFilterType()
is Qgis.SpatialFilterType.DistanceWithin then only features withindistanceWithin()
units of the reference geometry will be fetched.When a destination CRS is set using
setDestinationCrs()
, the geometry will be in the same CRS as thedestinationCrs()
. Otherwise, the geometry will use the same CRS as the source layer/provider.See also
New in version 3.22.
- Return type:
- requestMayBeNested(self) bool ¶
In case this request may be run nested within another already running iteration on the same connection, set this to
True
.If this flag is
True
, this request will be able to make use of “spare” connections to avoid deadlocks.For example, this should be set on requests that are issued from an expression function.
See also
New in version 3.4.
- Return type:
bool
- setConnectionTimeout(self, connectionTimeout: int) QgsFeatureRequest ¶
Sets the timeout (in milliseconds) for how long we should wait for a connection if none is available from the pool at this moment. A negative value (which is set by default) will wait forever.
Note
Only works if the provider supports this option.
Deprecated since version Use:
setTimeout()
instead.New in version 3.0.
- Parameters:
connectionTimeout (int) –
- Return type:
- setDestinationCrs(self, crs: QgsCoordinateReferenceSystem, context: QgsCoordinateTransformContext) QgsFeatureRequest ¶
Sets the destination
crs
for feature’s geometries. If set, all geometries will be reprojected from their original coordinate reference system to this desired reference system. Ifcrs
is an invalidQgsCoordinateReferenceSystem
then no reprojection will be done and all features will be left with their original geometry.When a
crs
is set usingsetDestinationCrs()
, then anyfilterRect()
orreferenceGeometry()
set on the request is expected to be in the same CRS as the destination CRS.The feature geometry transformation to the destination CRS is performed after all filter expressions are tested and any virtual fields are calculated. Accordingly, any geometric expressions used in
filterExpression()
will be performed in the original source CRS. This ensures consistent results are returned regardless of the destination CRS. Similarly, virtual field values will be calculated using the original geometry in the source CRS, so these values are not affected by any destination CRS transform present in the feature request.See also
New in version 3.0.
- Parameters:
crs (QgsCoordinateReferenceSystem) –
context (QgsCoordinateTransformContext) –
- Return type:
- setDistanceWithin(self, geometry: QgsGeometry, distance: float) QgsFeatureRequest ¶
Sets a reference
geometry
and a maximumdistance
from this geometry to retrieve features within.When a destination CRS is set using
setDestinationCrs()
,geometry
is expected to be in the same CRS as thedestinationCrs()
anddistance
is in the spatial units of thedestinationCrs()
. Otherwise,geometry
should use the same CRS as the source layer/provider anddistance
should use the spatial units as this same CRS.Calling this method will automatically set
spatialFilterType()
to Qgis.SpatialFilterType.DistanceWithin.See also
New in version 3.22.
- Parameters:
geometry (QgsGeometry) –
distance (float) –
- Return type:
- setExpressionContext(self, context: QgsExpressionContext) QgsFeatureRequest ¶
Sets the expression context used to evaluate filter expressions.
See also
See also
New in version 2.12.
- Parameters:
context (QgsExpressionContext) –
- Return type:
- setFeedback(self, feedback: QgsFeedback)¶
Attach a
feedback
object that can be queried regularly by the iterator to check if it should be canceled.Ownership of
feedback
is NOT transferred, and the caller must take care that it exists for the lifetime of the feature request and feature iterators.See also
New in version 3.20.
- Parameters:
feedback (QgsFeedback) –
- setFilterExpression(self, expression: str) QgsFeatureRequest ¶
Set the filter
expression
. {QgsExpression
}- Parameters:
expression (str) – expression string
Calling this method will automatically set
filterType()
to QgsFeatureRequest.FilterExpression.See also
See also
- Return type:
- setFilterFid(self, fid: int) QgsFeatureRequest ¶
Sets the feature ID that should be fetched.
Calling this method will automatically set
filterType()
to QgsFeatureRequest.FilterFid.See also
See also
- Parameters:
fid (int) –
- Return type:
- setFilterFids(self, fids: object) QgsFeatureRequest ¶
Sets the feature IDs that should be fetched.
Calling this method will automatically set
filterType()
to QgsFeatureRequest.FilterFids.See also
See also
- Parameters:
fids (object) –
- Return type:
- setFilterRect(self, rectangle: QgsRectangle) QgsFeatureRequest ¶
Sets the
rectangle
from which features will be taken. An empty rectangle removes the filter.When a destination CRS is set using
setDestinationCrs()
,rectangle
is expected to be in the same CRS as thedestinationCrs()
. Otherwise,rectangle
should use the same CRS as the source layer/provider.Calling this method will automatically set
spatialFilterType()
to Qgis.SpatialFilterType.BoundingBox. Ifrectangle
is a null rectangle thenspatialFilterType()
will be reset to Qgis.SpatialFilterType.NoFilter.See also
- Parameters:
rectangle (QgsRectangle) –
- Return type:
- setFlags(self, flags: QgsFeatureRequest.Flags | QgsFeatureRequest.Flag) QgsFeatureRequest ¶
Sets
flags
that affect how features will be fetched.See also
- Parameters:
flags (Union[QgsFeatureRequest.Flags) –
- Return type:
- setInvalidGeometryCallback(self, Callable[..., None]) QgsFeatureRequest ¶
Sets a callback function to use when encountering an invalid geometry and
invalidGeometryCheck()
is set to GeometryAbortOnInvalid or GeometrySkipInvalid. This function will be called using the feature with invalid geometry as a parameter.See also
invalidGeometryCallback()
New in version 3.0.
- Return type:
- setInvalidGeometryCheck(self, check: QgsFeatureRequest.InvalidGeometryCheck) QgsFeatureRequest ¶
Sets invalid geometry checking behavior.
Note
Invalid geometry checking is not performed when retrieving features directly from a
QgsVectorDataProvider
.See also
New in version 3.0.
- Parameters:
check (QgsFeatureRequest.InvalidGeometryCheck) –
- Return type:
- setLimit(self, limit: int) QgsFeatureRequest ¶
Set the maximum number of features to request.
- Parameters:
limit (int) – maximum number of features, or -1 to request all features.
See also
New in version 2.14.
- Return type:
- setNoAttributes(self) QgsFeatureRequest ¶
Set that no attributes will be fetched.
To revert a call to setNoAttributes and fetch all or some available attributes, the SubsetOfAttributes flag should be removed from the request.
Note
This is intended as hint to data providers for optimising feature retrieval. Depending on the provider, it may be trivial for the provider to always return all attributes instead of removing them. In these cases the provider may ignore this hint and return all attributes regardless of whether this method has been called.
See also
New in version 3.4.
- Return type:
- setOrderBy(self, orderBy: QgsFeatureRequest.OrderBy) QgsFeatureRequest ¶
Set a list of order by clauses.
New in version 2.14.
- Parameters:
orderBy (QgsFeatureRequest.OrderBy) –
- Return type:
- setRequestMayBeNested(self, requestMayBeNested: bool) QgsFeatureRequest ¶
In case this request may be run nested within another already running iteration on the same connection, set this to
True
.If this flag is
True
, this request will be able to make use of “spare” connections to avoid deadlocks.For example, this should be set on requests that are issued from an expression function.
See also
New in version 3.4.
- Parameters:
requestMayBeNested (bool) –
- Return type:
- setSimplifyMethod(self, simplifyMethod: QgsSimplifyMethod) QgsFeatureRequest ¶
Set a simplification method for geometries that will be fetched.
See also
New in version 2.2.
- Parameters:
simplifyMethod (QgsSimplifyMethod) –
- Return type:
- setSubsetOfAttributes(self, attrs: Iterable[int]) QgsFeatureRequest ¶
Set a subset of attributes that will be fetched.
An empty attributes list indicates that no attributes will be fetched. To revert a call to setSubsetOfAttributes and fetch all available attributes, the SubsetOfAttributes flag should be removed from the request.
Note
This is intended as hint to data providers for optimising feature retrieval. Depending on the provider, it may be trivial for the provider to always return all attributes instead of the requested subset, or actually result in slower retrieval when the attributes are filtered out. In these cases the provider may ignore this hint and return all attributes regardless of the requested attributes.
See also
See also
setSubsetOfAttributes(self, attrNames: Iterable[str], fields:
QgsFields
) -> QgsFeatureRequest Sets a subset of attributes by names that will be fetched.Note
This is intended as hint to data providers for optimising feature retrieval. Depending on the provider, it may be trivial for the provider to always return all attributes instead of the requested subset, or actually result in slower retrieval when the attributes are filtered out. In these cases the provider may ignore this hint and return all attributes regardless of the requested attributes.
See also
setSubsetOfAttributes(self, attrNames: Iterable[str], fields:
QgsFields
) -> QgsFeatureRequest Sets a subset of attributes by names that will be fetched.Note
This is intended as hint to data providers for optimising feature retrieval. Depending on the provider, it may be trivial for the provider to always return all attributes instead of the requested subset, or actually result in slower retrieval when the attributes are filtered out. In these cases the provider may ignore this hint and return all attributes regardless of the requested attributes.
See also
- Parameters:
attrs (Iterable[int]) –
- Return type:
- setTimeout(self, timeout: int) QgsFeatureRequest ¶
Sets the
timeout
(in milliseconds) for the maximum time we should wait during feature requests before a feature is returned. A negative value (which is set by default) will wait forever.Note
Only works if the provider supports this option.
See also
New in version 3.4.
- Parameters:
timeout (int) –
- Return type:
- setTransformErrorCallback(self, Callable[..., None]) QgsFeatureRequest ¶
Sets a callback function to use when encountering a transform error when iterating features and a
destinationCrs()
is set. This function will be called using the feature which encountered the transform error as a parameter.See also
transformErrorCallback()
See also
New in version 3.0.
- Return type:
- simplifyMethod(self) QgsSimplifyMethod ¶
Returns the simplification method for geometries that will be fetched.
See also
New in version 2.2.
- Return type:
- spatialFilterType(self) Qgis.SpatialFilterType ¶
Returns the spatial filter type which is currently set on this request.
This type will automatically be set to the appropriate value whenever
setFilterRect()
, orsetDistanceWithin()
are called.Note
A feature request may have both an attribute/ID filter AND a spatial filter set. See
filterType()
to retrieve the attribute/ID filter.See also
New in version 3.22.
- Return type:
- subsetOfAttributes(self) List[int] ¶
Returns the subset of attributes which at least need to be fetched.
- Return type:
List[int]
- Returns:
A list of attributes to be fetched
Note
This is intended as hint to data providers for optimising feature retrieval. Depending on the provider, it may be trivial for the provider to always return all attributes instead of the requested subset, or actually result in slower retrieval when the attributes are filtered out. In these cases the provider may ignore this hint and return all attributes regardless of the requested attributes.
See also
See also
- timeout(self) int ¶
Returns the timeout (in milliseconds) for the maximum time we should wait during feature requests before a feature is returned. A negative value (which is set by default) will wait forever.
Note
Only works if the provider supports this option.
See also
New in version 3.4.
- Return type:
int
- transformContext(self) QgsCoordinateTransformContext ¶
Returns the transform context, for use when a
destinationCrs()
has been set and reprojection is requiredSee also
See also
New in version 3.0.
- Return type: