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.

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
skip3DLayers: bool
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[source]

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.

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.

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:

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[source]

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.

signal identifyProgress[source]

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.

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.