Class: QgsScaleCalculator

class qgis.core.QgsScaleCalculator(dpi: float = 0, mapUnits: QgsUnitTypes.DistanceUnit = QgsUnitTypes.DistanceMeters)

Bases: sip.wrapper

Constructor

Parameters
  • dpi – Monitor resolution in dots per inch

  • mapUnits – Units of the data on the map

QgsScaleCalculator(QgsScaleCalculator)

Calculates scale for a given combination of canvas size, map extent, and monitor dpi.

Enums

Methods

calculate

Calculate the scale denominator

calculateGeographicDistance

Calculate the distance between two points in geographic coordinates.

dpi

Returns the DPI (dots per inch) used in scale calculations.

mapUnits

Returns current map units

setDpi

Sets the dpi (dots per inch) for the output resolution, to be used in scale calculations.

setMapUnits

Set the map units

Signals

Attributes

calculate(self, mapExtent: QgsRectangle, canvasWidth: float) → float

Calculate the scale denominator

Parameters
  • mapExtent – QgsRectangle containing the current map extent

  • canvasWidth – Width of the map canvas in pixel (physical) units

Returns

scale denominator of current map view, e.g. 1000.0 for a 1:1000 map.

calculateGeographicDistance(self, mapExtent: QgsRectangle) → float

Calculate the distance between two points in geographic coordinates. Used to calculate scale for map views with geographic (decimal degree) data.

Parameters

mapExtent – QgsRectangle containing the current map extent

dpi(self) → float

Returns the DPI (dots per inch) used in scale calculations.

See also

setDpi()

mapUnits(self) → QgsUnitTypes.DistanceUnit

Returns current map units

setDpi(self, dpi: float)

Sets the dpi (dots per inch) for the output resolution, to be used in scale calculations.

See also

dpi()

setMapUnits(self, mapUnits: QgsUnitTypes.DistanceUnit)

Set the map units

Parameters

mapUnits – Units of the data on the map. Must match a value from the