Class: QgsMapToolIdentifyFeature

class qgis.gui.QgsMapToolIdentifyFeature

Bases: QgsMapToolIdentify

The QgsMapToolIdentifyFeature class is a map tool to identify a feature on a chosen layer. Once the map tool is enable, user can click on the map canvas to identify a feature. A signal will then be emitted.

QgsMapToolIdentifyFeature(canvas: QgsMapCanvas, vl: QgsVectorLayer = None) QgsMapToolIdentifyFeature is a map tool to identify a feature on a chosen layer

Parameters:
canvasReleaseEvent(self, e: QgsMapMouseEvent)
Parameters:

e (QgsMapMouseEvent) –

childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
derivedAttributesForPoint(self, point: QgsPoint) Dict[str, str]

Returns derived attributes map for a clicked point in map coordinates. May be 2D or 3D point.

disconnectNotify(self, QMetaMethod)
featureIdentified

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

Parameters:
  • name (str = ...) –

  • revision (int = ...) –

  • arguments (Sequence = ...) –

Return type:

PYQT_SIGNAL

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 – x coordinates of mouseEvent

  • y – y coordinates of mouseEvent

  • layerList – Performs the identification within the given list of layers. Default value is an empty list, i.e. uses all the layers.

  • mode – Identification mode. Can use QGIS default settings or a defined mode. Default mode is DefaultQgsSetting.

  • identifyContext – 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.

Returns:

a list of IdentifyResult

identifyLayer(self, results: Iterable[QgsMapToolIdentify.IdentifyResult], layer: QgsMapLayer, point: QgsPointXY, viewExtent: QgsRectangle, mapUnitsPerPixel: float, layerType: QgsMapToolIdentify.LayerType | QgsMapToolIdentify.Type = QgsMapToolIdentify.AllLayers, identifyContext: QgsIdentifyContext = QgsIdentifyContext()) bool

Call the right method depending on layer 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.

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 – list of identify results

  • layer – raster layer to identify from

  • point – point coordinate to identify

  • viewExtent – view extent

  • mapUnitsPerPixel – map units per pixel value

  • identifyContext – identify context object

identifyVectorLayer(self, results: Iterable[QgsMapToolIdentify.IdentifyResult], layer: QgsVectorLayer, point: QgsPointXY, identifyContext: QgsIdentifyContext = QgsIdentifyContext()) bool

Performs the identification against a given vector layer.

Parameters:
  • results – list of identify results

  • layer – raster layer to identify from

  • point – point coordinate to identify

  • identifyContext – identify context object

isSignalConnected(self, QMetaMethod) bool
keyPressEvent(self, e: QKeyEvent)
Parameters:

e (QKeyEvent) –

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 the QgsProject 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 a QgsProject.

New in version 3.22.

receivers(self, PYQT_SIGNAL) int
restoreCanvasPropertiesOverrides(self)

Clears canvas properties overrides previously set with setCanvasPropertiesOverrides()

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.

New in version 3.4.

setLayer(self, vl: QgsVectorLayer)

change the layer used by the map tool to identify

Parameters:

vl (QgsVectorLayer) –

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 to layer coordinates.

toLayerCoordinates(self, layer: QgsMapLayer, point: QgsPointXY) -> QgsPointXY Transforms a point from map coordinates to layer coordinates.

toLayerCoordinates(self, layer: QgsMapLayer, rect: QgsRectangle) -> QgsRectangle Transforms a rect from map coordinates to layer coordinates.

toLayerCoordinatesV2(self, layer: QgsMapLayer, point: QgsPoint) QgsPoint

Transforms a point from map coordinates to layer 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 a point from layer coordinates to map coordinates (which is different in case reprojection is used).

toMapCoordinatesV2(self, layer: QgsMapLayer, point: QgsPoint) QgsPoint

Transforms a point from layer coordinates to map coordinates (which is different in case reprojection is used).

Note

This method is available in the Python bindings as toMapCoordinatesV2.