Subgroup: Scale
Class: QgsScaleCalculator¶
-
class
qgis.core.
QgsScaleCalculator
¶ Bases:
sip.wrapper
Calculates scale for a given combination of canvas size, map extent, and monitor dpi.
Methods
calculate
Calculate the scale denominator calculateGeographicDistance
Calculate the distance between two points in geographic coordinates. dpi
Accessor for dpi used in scale calculations mapUnits
Returns current map units setDpi
Set the dpi to be used in scale calculations setMapUnits
Set the map units Attributes
-
calculate
(self, mapExtent: QgsRectangle, canvasWidth: int) → 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¶ Accessor for dpi used in scale calculations
Returns: int the dpi used for scale calculations.
-
mapUnits
(self) → QgsUnitTypes.DistanceUnit¶ Returns current map units
-
setDpi
(self, dpi: float)¶ Set the dpi to be used in scale calculations
Parameters: dpi – Dots per inch of monitor resolution
-
setMapUnits
(self, mapUnits: QgsUnitTypes.DistanceUnit)¶ Set the map units
Parameters: mapUnits – Units of the data on the map. Must match a value from the
-