Class: QgsMapToolIdentify

Map tool for identifying features in layers.

After the tool is used to select a point, this map tool 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)

Class Hierarchy

Inheritance diagram of qgis.gui.QgsMapToolIdentify

Base classes

QgsMapTool

Abstract base class for all map tools.

QObject

Subclasses

QgsMapToolIdentifyFeature

A map tool to identify a feature on a chosen layer.

Methods

derivedAttributesForPoint

Returns derived attributes map for a clicked point in map coordinates.

formatChanged

identify

Performs the identification.

identifyLayer

Call the right method depending on layer type

identifyMenu

Returns a pointer to the identify menu which will be used in layer selection mode this menu can also be customized

identifyMeshLayer

Identifies data from active scalar and vector dataset from the mesh layer

identifyRasterLayer

Performs the identification against a given raster layer.

identifyVectorLayer

Performs the identification against a given vector layer.

restoreCanvasPropertiesOverrides

Clears canvas properties overrides previously set with setCanvasPropertiesOverrides()

restorePropertiesOverrides

Clears canvas properties overrides previously set with setPropertiesOverrides()

setCanvasPropertiesOverrides

Overrides some map canvas properties inside the map tool for the upcoming identify requests.

setPropertiesOverrides

Overrides some map canvas properties inside the map tool for the upcoming identify requests.

Signals

changedRasterResults

Emitted when the format of raster results is changed and need to be updated in user-facing displays.

identifyMessage

Emitted when the identify operation needs to show a user-facing message

identifyProgress

Emitted when the identify action progresses.

Attributes

ActiveLayer

AllLayers

DefaultQgsSetting

LayerSelection

MeshLayer

PointCloudLayer

RasterLayer

TopDownAll

TopDownStopAtFirst

VectorLayer

VectorTileLayer

class qgis.gui.QgsMapToolIdentify[source]

Bases: QgsMapTool

__init__(canvas: QgsMapCanvas | None)

constructor

Parameters:

canvas (Optional[QgsMapCanvas])

ActiveLayer = 0
AllLayers = 31
DefaultQgsSetting = -1
class IdentifyMode

Bases: int

class IdentifyProperties
class IdentifyProperties(a0: QgsMapToolIdentify.IdentifyProperties)

Bases: object

searchRadiusMapUnits: float

Identify search radius is map units. Use negative value to ignore

skip3DLayers: bool

Skip identify results from layers that have a 3d renderer set

class IdentifyResult
class IdentifyResult(layer: QgsMapLayer | None, feature: QgsFeature, derivedAttributes: Dict[str | None, str | None])
class IdentifyResult(layer: QgsMapLayer | None, label: str | None, attributes: Dict[str | None, str | None], derivedAttributes: Dict[str | None, str | None])
class IdentifyResult(layer: QgsMapLayer | None, label: str | None, fields: QgsFields, feature: QgsFeature, derivedAttributes: Dict[str | None, str | None])
class IdentifyResult(a0: QgsMapToolIdentify.IdentifyResult)

Bases: object

mAttributes
mDerivedAttributes
mFeature
mFields
mLabel
mLayer
mParams
LayerSelection = 3
class LayerType
class LayerType(f: QgsMapToolIdentify.LayerType | QgsMapToolIdentify.Type)
class LayerType(a0: QgsMapToolIdentify.LayerType)

Bases: object

MeshLayer = 4
PointCloudLayer = 16
RasterLayer = 2
TopDownAll = 2
TopDownStopAtFirst = 1
class Type

Bases: int

VectorLayer = 1
VectorTileLayer = 8
signal changedRasterResults(results: List[QgsMapToolIdentify.IdentifyResult])[source]

Emitted when the format of raster results is changed and need to be updated in user-facing displays.

Parameters:

results (List[QgsMapToolIdentify.IdentifyResult])

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]

formatChanged(self, layer: QgsRasterLayer | None)[source]
Parameters:

layer (Optional[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.

Return type:

List[QgsMapToolIdentify.IdentifyResult]

Returns:

a list of IdentifyResult

identify(self, x: int, y: int, mode: QgsMapToolIdentify.IdentifyMode, layerType: 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 (int) – x coordinates of mouseEvent

  • y (int) – y coordinates of mouseEvent

  • mode (QgsMapToolIdentify.IdentifyMode) – Identification mode. Can use QGIS default settings or a defined mode.

  • layerType (Union[QgsMapToolIdentify.LayerType, QgsMapToolIdentify.Type] = QgsMapToolIdentify.AllLayers) – Only performs identification in a certain type of layers (raster, vector, mesh). Default value is AllLayers.

  • identifyContext (QgsIdentifyContext = QgsIdentifyContext()) – Identify context object.

Return type:

List[QgsMapToolIdentify.IdentifyResult]

Returns:

a list of IdentifyResult

identify(self, geometry: QgsGeometry, mode: QgsMapToolIdentify.IdentifyMode, layerType: QgsMapToolIdentify.LayerType | QgsMapToolIdentify.Type, identifyContext: QgsIdentifyContext = QgsIdentifyContext()) List[QgsMapToolIdentify.IdentifyResult]

Performs identification based on a geometry (in map coordinates)

Parameters:
Return type:

List[QgsMapToolIdentify.IdentifyResult]

identify(self, geometry: QgsGeometry, mode: QgsMapToolIdentify.IdentifyMode, layerList: Iterable[QgsMapLayer], layerType: QgsMapToolIdentify.LayerType | QgsMapToolIdentify.Type, identifyContext: QgsIdentifyContext = QgsIdentifyContext()) List[QgsMapToolIdentify.IdentifyResult]

Performs identification based on a geometry (in map coordinates)

Parameters:
Return type:

List[QgsMapToolIdentify.IdentifyResult]

identify(self, x: int, y: int, mode: QgsMapToolIdentify.IdentifyMode, layerList: Iterable[QgsMapLayer], layerType: 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 (int) – x coordinates of mouseEvent

  • y (int) – y coordinates of mouseEvent

  • mode (QgsMapToolIdentify.IdentifyMode) – Identification mode. Can use QGIS default settings or a defined mode.

  • layerList (Iterable[QgsMapLayer]) – Performs the identification within the given list of layers.

  • layerType (Union[QgsMapToolIdentify.LayerType, QgsMapToolIdentify.Type] = QgsMapToolIdentify.AllLayers) – Only performs identification in a certain type of layers (raster, vector, mesh).

  • identifyContext (QgsIdentifyContext = QgsIdentifyContext()) – Identify context object.

Return type:

List[QgsMapToolIdentify.IdentifyResult]

Returns:

a list of IdentifyResult

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

Call the right method depending on layer type

Parameters:
Return type:

bool

identifyMenu(self) QgsIdentifyMenu | None[source]

Returns a pointer to the identify menu which will be used in layer selection mode this menu can also be customized

Return type:

Optional[QgsIdentifyMenu]

identifyMeshLayer(self, results: Iterable[QgsMapToolIdentify.IdentifyResult] | None, layer: QgsMeshLayer | None, point: QgsPointXY, identifyContext: QgsIdentifyContext = QgsIdentifyContext()) bool[source]

Identifies data from active scalar and vector dataset from the mesh layer

Works only if layer was already rendered (triangular mesh is created)

Added in version 3.6.

Parameters:
Return type:

bool

signal identifyMessage(message: str)[source]

Emitted when the identify operation needs to show a user-facing message

Parameters:

message (str) – Message to show to the user

signal identifyProgress(processed: int, total: int)[source]

Emitted when the identify action progresses.

Parameters:
  • processed (int) – number of objects processed so far

  • total (int) – total number of objects to process

identifyRasterLayer(self, results: Iterable[QgsMapToolIdentify.IdentifyResult] | None, layer: QgsRasterLayer | None, point: QgsPointXY, viewExtent: QgsRectangle, mapUnitsPerPixel: float, identifyContext: QgsIdentifyContext = QgsIdentifyContext()) bool[source]

Performs the identification against a given raster layer.

Parameters:
Return type:

bool

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

Performs the identification against a given vector layer.

Parameters:
Return type:

bool

restoreCanvasPropertiesOverrides(self)[source]

Clears canvas properties overrides previously set with setCanvasPropertiesOverrides()

Added in version 3.4.

Deprecated since version 3.42: Use restorePropertiesOverrides() instead.

restorePropertiesOverrides(self)[source]

Clears canvas properties overrides previously set with setPropertiesOverrides()

Added in version 3.42.

setCanvasPropertiesOverrides(self, searchRadiusMapUnits: float)[source]

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. When the custom identification has finished, restoreCanvasPropertiesOverrides() should be called to erase any overrides.

Parameters:

searchRadiusMapUnits (float) – The overridden search radius in map units

Added in version 3.4.

Deprecated since version 3.42: Use setPropertiesOverrides() instead.

setPropertiesOverrides(self, overrides: QgsMapToolIdentify.IdentifyProperties)[source]

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. When the custom identification has finished, restorePropertiesOverrides() should be called to erase any overrides.

Parameters:

overrides (QgsMapToolIdentify.IdentifyProperties) – The identify tool properties that will be overridden

Added in version 3.42.