Class: QgsScaleCalculator¶
- class qgis.core.QgsScaleCalculator¶
Bases:
sip.wrapper
Calculates scale for a given combination of canvas size, map extent, and monitor dpi.
QgsScaleCalculator(dpi: float = 0, mapUnits: QgsUnitTypes.DistanceUnit = QgsUnitTypes.DistanceMeters) Constructor
- Parameters:
dpi – Monitor resolution in dots per inch
mapUnits – Units of the data on the map
QgsScaleCalculator(
QgsScaleCalculator
)Methods
Calculate the scale denominator
Calculate the distance between two points in geographic coordinates.
Returns the DPI (dots per inch) used in scale calculations.
Returns current map units
Sets the
dpi
(dots per inch) for the output resolution, to be used in scale calculations.Set the map units
- calculate(self, mapExtent: QgsRectangle, canvasWidth: float) float ¶
Calculate the scale denominator
- Parameters:
mapExtent (QgsRectangle) –
QgsRectangle
containing the current map extentcanvasWidth (float) – Width of the map canvas in pixel (physical) units
- Return type:
float
- 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) –
QgsRectangle
containing the current map extent- Return type:
float
- dpi(self) float ¶
Returns the DPI (dots per inch) used in scale calculations.
See also
- Return type:
float
- mapUnits(self) QgsUnitTypes.DistanceUnit ¶
Returns current map units
- Return type:
- setDpi(self, dpi: float)¶
Sets the
dpi
(dots per inch) for the output resolution, to be used in scale calculations.See also
- Parameters:
dpi (float) –
- setMapUnits(self, mapUnits: QgsUnitTypes.DistanceUnit)¶
Set the map units
- Parameters:
mapUnits (QgsUnitTypes.DistanceUnit) – Units of the data on the map. Must match a value from the