Class: QgsMapToolIdentify¶
- class qgis.gui.QgsMapToolIdentify¶
Bases:
QgsMapTool
Map tool for identifying features in layers
after selecting a point, performs the identification:
for raster layers shows value of underlying pixel
for vector layers shows feature attributes within search radius (allows editing values when vector layer is in editing mode)
QgsMapToolIdentify(canvas:
QgsMapCanvas
) constructorMethods
- param e
- param e
- param e
Returns derived attributes map for a clicked point in map coordinates.
- rtype
QgsMapTool.Flags
- param layer
Performs the identification.
Call the right method depending on layer type
Returns a pointer to the identify menu which will be used in layer selection mode this menu can also be customized
Identifies data from active scalar and vector dataset from the mesh layer
Performs the identification against a given raster layer.
Performs the identification against a given vector layer.
Returns the map layer with the matching ID, or
None
if no layers could be found.Clears canvas properties overrides previously set with
setCanvasPropertiesOverrides()
Overrides some map canvas properties inside the map tool for the upcoming identify requests.
Sets the tool's
name
.Transforms a
point
from map coordinates to screen coordinates.Transforms a
point
from screen coordinates tolayer
coordinates.Transforms a
point
from map coordinates tolayer
coordinates.Transforms a
point
from screen coordinates to map coordinates.Transforms a
point
fromlayer
coordinates to map coordinates (which is different in case reprojection is used).Signals
changedRasterResults(self, Iterable[QgsMapToolIdentify.IdentifyResult]) [signal]
identifyMessage(self, str) [signal]
identifyProgress(self, int, int) [signal]
Attributes
- ActiveLayer = 0¶
- AllLayers = 31¶
- DefaultQgsSetting = -1¶
- class IdentifyMode¶
Bases:
int
- baseClass¶
alias of
QgsMapToolIdentify
- class IdentifyResult¶
Bases:
sip.wrapper
Constructor for IdentifyResult
QgsMapToolIdentify.IdentifyResult(layer:
QgsMapLayer
, feature:QgsFeature
, derivedAttributes: Dict[str, str])QgsMapToolIdentify.IdentifyResult(layer:
QgsMapLayer
, label: str, attributes: Dict[str, str], derivedAttributes: Dict[str, str])QgsMapToolIdentify.IdentifyResult(layer:
QgsMapLayer
, label: str, fields:QgsFields
, feature:QgsFeature
, derivedAttributes: Dict[str, str])QgsMapToolIdentify.IdentifyResult(QgsMapToolIdentify.IdentifyResult)
- mAttributes¶
- mDerivedAttributes¶
- mFeature¶
- mFields¶
- mLabel¶
- mLayer¶
- mParams¶
- LayerSelection = 3¶
- class LayerType¶
- class LayerType(Union[QgsMapToolIdentify.LayerType, QgsMapToolIdentify.Type])
- class LayerType(QgsMapToolIdentify.LayerType)
Bases:
sip.wrapper
- baseClass¶
alias of
QgsMapToolIdentify
- MeshLayer = 4¶
- PointCloudLayer = 16¶
- RasterLayer = 2¶
- TopDownAll = 2¶
- TopDownStopAtFirst = 1¶
- class Type¶
Bases:
int
- VectorLayer = 1¶
- VectorTileLayer = 8¶
- activate(self)¶
- canvasMoveEvent(self, e: QgsMapMouseEvent)¶
- Parameters
e (QgsMapMouseEvent) –
- canvasPressEvent(self, e: QgsMapMouseEvent)¶
- Parameters
e (QgsMapMouseEvent) –
- canvasReleaseEvent(self, e: QgsMapMouseEvent)¶
- Parameters
e (QgsMapMouseEvent) –
- changedRasterResults¶
changedRasterResults(self, Iterable[QgsMapToolIdentify.IdentifyResult]) [signal]
- childEvent(self, QChildEvent)¶
- connectNotify(self, QMetaMethod)¶
- customEvent(self, QEvent)¶
- deactivate(self)¶
- derivedAttributesForPoint(self, point: QgsPoint) Dict[str, str] ¶
Returns derived attributes map for a clicked point in map coordinates. May be 2D or 3D point.
- Parameters
point (QgsPoint) –
- Return type
Dict[str, str]
- disconnectNotify(self, QMetaMethod)¶
- flags(self) QgsMapTool.Flags ¶
- Return type
- formatChanged(self, layer: QgsRasterLayer)¶
- Parameters
layer (QgsRasterLayer) –
- identify(self, x: int, y: int, layerList: Iterable[QgsMapLayer] = [], mode: QgsMapToolIdentify.IdentifyMode = QgsMapToolIdentify.DefaultQgsSetting, identifyContext: QgsIdentifyContext = QgsIdentifyContext()) List[QgsMapToolIdentify.IdentifyResult] ¶
Performs the identification.
- Parameters
x (int) – x coordinates of mouseEvent
y (int) – y coordinates of mouseEvent
layerList (Iterable[QgsMapLayer] = []) – Performs the identification within the given list of layers. Default value is an empty list, i.e. uses all the layers.
mode (QgsMapToolIdentify.IdentifyMode = QgsMapToolIdentify.DefaultQgsSetting) – Identification mode. Can use QGIS default settings or a defined mode. Default mode is DefaultQgsSetting.
identifyContext (
QgsIdentifyContext
= QgsIdentifyContext()) – Identify context object.
- Returns
a list of IdentifyResult
identify(self, x: int, y: int, mode: QgsMapToolIdentify.IdentifyMode, layerType: Union[QgsMapToolIdentify.LayerType, QgsMapToolIdentify.Type] = QgsMapToolIdentify.AllLayers, identifyContext:
QgsIdentifyContext
= QgsIdentifyContext()) -> List[QgsMapToolIdentify.IdentifyResult] Performs the identification. To avoid being forced to specify IdentifyMode with a list of layers this has been made private and two publics methods are offered- Parameters
x – x coordinates of mouseEvent
y – y coordinates of mouseEvent
mode – Identification mode. Can use QGIS default settings or a defined mode.
layerType – Only performs identification in a certain type of layers (raster, vector, mesh). Default value is AllLayers.
identifyContext – Identify context object.
- Returns
a list of IdentifyResult
identify(self, geometry:
QgsGeometry
, mode: QgsMapToolIdentify.IdentifyMode, layerType: Union[QgsMapToolIdentify.LayerType, QgsMapToolIdentify.Type], identifyContext:QgsIdentifyContext
= QgsIdentifyContext()) -> List[QgsMapToolIdentify.IdentifyResult] Performs identification based on a geometry (in map coordinates)identify(self, geometry:
QgsGeometry
, mode: QgsMapToolIdentify.IdentifyMode, layerList: Iterable[QgsMapLayer], layerType: Union[QgsMapToolIdentify.LayerType, QgsMapToolIdentify.Type], identifyContext:QgsIdentifyContext
= QgsIdentifyContext()) -> List[QgsMapToolIdentify.IdentifyResult] Performs identification based on a geometry (in map coordinates)identify(self, x: int, y: int, mode: QgsMapToolIdentify.IdentifyMode, layerList: Iterable[QgsMapLayer], layerType: Union[QgsMapToolIdentify.LayerType, QgsMapToolIdentify.Type] = QgsMapToolIdentify.AllLayers, identifyContext:
QgsIdentifyContext
= QgsIdentifyContext()) -> List[QgsMapToolIdentify.IdentifyResult] Performs the identification. To avoid being forced to specify IdentifyMode with a list of layers this has been made private and two publics methods are offered- Parameters
x – x coordinates of mouseEvent
y – y coordinates of mouseEvent
mode – Identification mode. Can use QGIS default settings or a defined mode.
layerList – Performs the identification within the given list of layers.
layerType – Only performs identification in a certain type of layers (raster, vector, mesh).
identifyContext – Identify context object.
- Return type
- Returns
a list of IdentifyResult
- identifyLayer(self, results: Iterable[QgsMapToolIdentify.IdentifyResult], layer: QgsMapLayer, point: QgsPointXY, viewExtent: QgsRectangle, mapUnitsPerPixel: float, layerType: Union[QgsMapToolIdentify.LayerType, QgsMapToolIdentify.Type] = QgsMapToolIdentify.AllLayers, identifyContext: QgsIdentifyContext = QgsIdentifyContext()) bool ¶
Call the right method depending on layer type
- Parameters
results (Iterable[QgsMapToolIdentify.IdentifyResult]) –
layer (QgsMapLayer) –
point (QgsPointXY) –
viewExtent (QgsRectangle) –
mapUnitsPerPixel (float) –
layerType (Union[QgsMapToolIdentify.LayerType) –
identifyContext (
QgsIdentifyContext
= QgsIdentifyContext()) –
- Return type
bool
- identifyMenu(self) QgsIdentifyMenu ¶
Returns a pointer to the identify menu which will be used in layer selection mode this menu can also be customized
- Return type
- identifyMeshLayer(self, results: Iterable[QgsMapToolIdentify.IdentifyResult], layer: QgsMeshLayer, point: QgsPointXY, identifyContext: QgsIdentifyContext = QgsIdentifyContext()) bool ¶
Identifies data from active scalar and vector dataset from the mesh layer
Works only if layer was already rendered (triangular mesh is created)
New in version 3.6.
- Parameters
results (Iterable[QgsMapToolIdentify.IdentifyResult]) –
layer (QgsMeshLayer) –
point (QgsPointXY) –
identifyContext (
QgsIdentifyContext
= QgsIdentifyContext()) –
- Return type
bool
- identifyMessage¶
identifyMessage(self, str) [signal]
- identifyProgress¶
identifyProgress(self, int, int) [signal]
- identifyRasterLayer(self, results: Iterable[QgsMapToolIdentify.IdentifyResult], layer: QgsRasterLayer, point: QgsPointXY, viewExtent: QgsRectangle, mapUnitsPerPixel: float, identifyContext: QgsIdentifyContext = QgsIdentifyContext()) bool ¶
Performs the identification against a given raster layer.
- Parameters
results (Iterable[QgsMapToolIdentify.IdentifyResult]) – list of identify results
layer (QgsRasterLayer) – raster layer to identify from
point (QgsPointXY) – point coordinate to identify
viewExtent (QgsRectangle) – view extent
mapUnitsPerPixel (float) – map units per pixel value
identifyContext (
QgsIdentifyContext
= QgsIdentifyContext()) – identify context object
- Return type
bool
- identifyVectorLayer(self, results: Iterable[QgsMapToolIdentify.IdentifyResult], layer: QgsVectorLayer, point: QgsPointXY, identifyContext: QgsIdentifyContext = QgsIdentifyContext()) bool ¶
Performs the identification against a given vector layer.
- Parameters
results (Iterable[QgsMapToolIdentify.IdentifyResult]) – list of identify results
layer (QgsVectorLayer) – raster layer to identify from
point (QgsPointXY) – point coordinate to identify
identifyContext (
QgsIdentifyContext
= QgsIdentifyContext()) – identify context object
- Return type
bool
- isSignalConnected(self, QMetaMethod) bool ¶
- layer(self, id: str) QgsMapLayer ¶
Returns the map layer with the matching ID, or
None
if no layers could be found.This method searches both layers associated with the map canvas (see
QgsMapCanvas.layers()
) and layers from theQgsProject
associated with the canvas. It can be used to resolve layer IDs to layers which may be visible in the canvas, but not associated with aQgsProject
.New in version 3.22.
- receivers(self, PYQT_SIGNAL) int ¶
- restoreCanvasPropertiesOverrides(self)¶
Clears canvas properties overrides previously set with
setCanvasPropertiesOverrides()
See also
New in version 3.4.
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- setCanvasPropertiesOverrides(self, searchRadiusMapUnits: float)¶
Overrides some map canvas properties inside the map tool for the upcoming identify requests.
This is useful when the identification is triggered by some other piece of GUI like a 3D map view and some properties like search radius need to be adjusted so that identification returns correct results. Currently only search radius may be overridden.
When the custom identification has finished,
restoreCanvasPropertiesOverrides()
should be called to erase any overrides.See also
New in version 3.4.
- Parameters
searchRadiusMapUnits (float) –
- setToolName(self, name: str)¶
Sets the tool’s
name
.See also
toolName()
New in version 3.20.
- timerEvent(self, QTimerEvent)¶
- toCanvasCoordinates(self, point: QgsPointXY) QPoint ¶
Transforms a
point
from map coordinates to screen coordinates.
- toLayerCoordinates(self, layer: QgsMapLayer, point: QPoint) QgsPointXY ¶
Transforms a
point
from screen coordinates tolayer
coordinates.toLayerCoordinates(self, layer:
QgsMapLayer
, point:QgsPointXY
) -> QgsPointXY Transforms apoint
from map coordinates tolayer
coordinates.toLayerCoordinates(self, layer:
QgsMapLayer
, rect:QgsRectangle
) -> QgsRectangle Transforms arect
from map coordinates tolayer
coordinates.
- toLayerCoordinatesV2(self, layer: QgsMapLayer, point: QgsPoint) QgsPoint ¶
Transforms a
point
from map coordinates tolayer
coordinates.Note
This method is available in the Python bindings as toLayerCoordinatesV2.
- toMapCoordinates(self, point: QPoint) QgsPointXY ¶
Transforms a
point
from screen coordinates to map coordinates.toMapCoordinates(self, layer:
QgsMapLayer
, point:QgsPointXY
) -> QgsPointXY Transforms apoint
fromlayer
coordinates to map coordinates (which is different in case reprojection is used).
- toMapCoordinatesV2(self, layer: QgsMapLayer, point: QgsPoint) QgsPoint ¶
Transforms a
point
fromlayer
coordinates to map coordinates (which is different in case reprojection is used).Note
This method is available in the Python bindings as toMapCoordinatesV2.