Class: QgsSnapToGridCanvasItem

Shows a grid on the map canvas given a spatial resolution.

Added in version 3.4.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsSnapToGridCanvasItem

Base classes

QgsMapCanvasItem

An abstract class for items that can be placed on the map canvas.

QGraphicsItem

Methods

crs

The CRS in which the grid should be calculated.

enabled

Enable this item.

point

A point that will be highlighted on the map canvas.

precision

The resolution of the grid in map units.

setCrs

The CRS in which the grid should be calculated.

setEnabled

Enable this item.

setPoint

A point that will be highlighted on the map canvas.

setPrecision

The resolution of the grid in map units.

class qgis.gui.QgsSnapToGridCanvasItem[source]

Bases: QgsMapCanvasItem

__init__(mapCanvas: QgsMapCanvas | None)

Will automatically be added to the mapCanvas.

Parameters:

mapCanvas (Optional[QgsMapCanvas])

crs(self) QgsCoordinateReferenceSystem[source]

The CRS in which the grid should be calculated. By default will be an invalid QgsCoordinateReferenceSystem and as such equal to the CRS of the map canvas.

Return type:

QgsCoordinateReferenceSystem

enabled(self) bool[source]

Enable this item. It will be hidden if disabled.

Return type:

bool

point(self) QgsPointXY[source]

A point that will be highlighted on the map canvas. The point needs to be in map coordinates. The closest point on the grid will be highlighted.

Return type:

QgsPointXY

precision(self) float[source]

The resolution of the grid in map units. If a crs has been specified it will be in CRS units.

Return type:

float

setCrs(self, crs: QgsCoordinateReferenceSystem)[source]

The CRS in which the grid should be calculated. By default will be an invalid QgsCoordinateReferenceSystem and as such equal to the CRS of the map canvas.

Parameters:

crs (QgsCoordinateReferenceSystem)

setEnabled(self, enabled: bool)[source]

Enable this item. It will be hidden if disabled.

Parameters:

enabled (bool)

setPoint(self, point: QgsPointXY)[source]

A point that will be highlighted on the map canvas. The point needs to be in map coordinates. The closest point on the grid will be highlighted.

Parameters:

point (QgsPointXY)

setPrecision(self, precision: float)[source]

The resolution of the grid in map units. If a crs has been specified it will be in CRS units.

Parameters:

precision (float)