Subgroup: Map
Class: QgsMapToPixel¶
-
class
qgis.core.
QgsMapToPixel
(mapUnitsPerPixel: float, centerX: float, centerY: float, widthPixels: int, heightPixels: int, rotation: float)¶ Bases:
sip.wrapper
Constructor
Parameters: - mapUnitsPerPixel – Map units per pixel
- centerX – X coordinate of map center, in geographical units
- centerY – Y coordinate of map center, in geographical units
- widthPixels – Output width, in pixels
- heightPixels – Output height, in pixels
- rotation – clockwise rotation in degrees
New in version 2.8.
QgsMapToPixel(mapUnitsPerPixel: float) Constructor
Parameters: mapUnitsPerPixel – Map units per pixel QgsMapToPixel() Constructor
Use setParameters to fill
QgsMapToPixel(QgsMapToPixel)
Perform transforms between map coordinates and device coordinates.
This class can convert device coordinates to map coordinates and vice versa.
Methods
fromScale
Returns a new QgsMapToPixel created using a specified scale
and distance unit.mapHeight
Returns current map height in pixels mapRotation
Returns current map rotation in degrees mapUnitsPerPixel
Returns current map units per pixel mapWidth
Returns current map width in pixels The information is only known if setRotation was used setMapRotation
Set map rotation in degrees (clockwise) setMapUnitsPerPixel
Set map units per pixel setParameters
Set parameters for use in transforming coordinates showParameters
String representation of the parameters used in the transform toMapCoordinates
toMapCoordinates(self, p: QPoint) -> QgsPointXY Transform device coordinates to map (world) coordinates toMapCoordinatesF
Transform device coordinates to map (world) coordinates toMapPoint
transform
Transform the point from map (world) coordinates to device coordinates transformInPlace
Transform device coordinates to map coordinates. xCenter
Returns the center x-coordinate for the transform. yCenter
Returns the center y-coordinate for the transform. Signals
Attributes
-
fromScale
(scale: float, mapUnits: QgsUnitTypes.DistanceUnit, dpi: float = 96) → QgsMapToPixel¶ Returns a new QgsMapToPixel created using a specified
scale
and distance unit.Parameters: - scale – map scale denominator, e.g. 1000.0 for a 1:1000 map.
- dpi – screen DPI
- mapUnits – map units
Returns: matching QgsMapToPixel
New in version 3.0.
-
mapHeight
(self) → int¶ Returns current map height in pixels
New in version 2.8.
-
mapRotation
(self) → float¶ Returns current map rotation in degrees
New in version 2.8.
-
mapUnitsPerPixel
(self) → float¶ Returns current map units per pixel
-
mapWidth
(self) → int¶ Returns current map width in pixels The information is only known if setRotation was used
New in version 2.8.
-
setMapRotation
(self, degrees: float, cx: float, cy: float)¶ Set map rotation in degrees (clockwise)
Parameters: - degrees – clockwise rotation in degrees
- cx – X ordinate of map center in geographical units
- cy – Y ordinate of map center in geographical units
New in version 2.8.
-
setMapUnitsPerPixel
(self, mapUnitsPerPixel: float)¶ Set map units per pixel
Parameters: mapUnitsPerPixel – Map units per pixel
-
setParameters
(self, mapUnitsPerPixel: float, centerX: float, centerY: float, widthPixels: int, heightPixels: int, rotation: float)¶ Set parameters for use in transforming coordinates
Parameters: - mapUnitsPerPixel – Map units per pixel
- centerX – X coordinate of map center, in geographical units
- centerY – Y coordinate of map center, in geographical units
- widthPixels – Output width, in pixels
- heightPixels – Output height, in pixels
- rotation – clockwise rotation in degrees
New in version 2.8.
-
showParameters
(self) → str¶ String representation of the parameters used in the transform
-
toMapCoordinates
(self, x: int, y: int) → QgsPointXY¶ toMapCoordinates(self, p: QPoint) -> QgsPointXY Transform device coordinates to map (world) coordinates
Parameters: p – Point to be converted to map cooordinates Returns: QgsPointXY in map coorndiates
-
toMapCoordinatesF
(self, x: float, y: float) → QgsPointXY¶ Transform device coordinates to map (world) coordinates
-
toMapPoint
(self, x: float, y: float) → QgsPointXY¶
-
transform
(self, p: QgsPointXY) → QgsPointXY¶ Transform the point from map (world) coordinates to device coordinates
Parameters: p – Point to transform Returns: QgsPointXY in device coordinates transform(self, p: QgsPointXY)
transform(self, x: float, y: float) -> QgsPointXY Transform the point specified by x,y from map (world) coordinates to device coordinates
Parameters: - x – x cordinate o point to transform
- y – y coordinate of point to transform
Returns: QgsPointXY in device coordinates
transform(self) -> QTransform
-
transformInPlace
(self) → Tuple[float, float]¶ Transform device coordinates to map coordinates. Modifies the given coordinates in place. Intended as a fast way to do the transform.
-
xCenter
(self) → float¶ Returns the center x-coordinate for the transform.
See also
New in version 3.0.