CRSHandler
Import
from pyqgis_wrapper.projection import CRSHandler
Warning
The reprojection import the processing library and needs to be executed within an environment able to use it.
You can still construct CRS without it.
CRSHandler(layer, feedback=QgsProcessingFeedback(), context=QgsProcessingContext())
¶
Handles CRS construction and reprojection
Attributes:
| Name | Type | Description |
|---|---|---|
ALGS |
Dict[QgsMapLayer, str]
|
Processing algorithm for reprojection. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer
|
qgis.core.QgsMapLayer
|
Layer to reproject |
required |
feedback
|
qgis.core.QgsProcessingFeedback
|
Feedback object if executed within QGIS, defaults to QgsProcessingFeedback() |
qgis.core.QgsProcessingFeedback()
|
context
|
qgis.core.QgsProcessingContext
|
Context in which the algorithm is being used, defaults to QgsProcessingContext() |
qgis.core.QgsProcessingContext()
|
Source code in pyqgis_wrapper/projection/crs_handler.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
build_crs(crs)
staticmethod
¶
Build a QgsCoordinateReferenceSystem from an epsg code
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
epsg_code
|
typing.Union[str, int, qgis.core.QgsCoordinateReferenceSystem]
|
Either an int or a string or direclt a QgsCoordinateReferenceSystem It can be : "EPSG:4326", "4326" or 4326 |
required |
Returns:
| Type | Description |
|---|---|
QgsCoordinateTransform
|
Constructed CRS object |
Source code in pyqgis_wrapper/projection/crs_handler.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | |
reproject(layer, target_crs=None, feedback=QgsProcessingFeedback(), context=QgsProcessingContext())
classmethod
¶
Reproject a layer to a target CRS. If there is no target CRS provided then it'll reproject to an available CRS (m) if the layer is in a geographic (°) CRS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer
|
qgis.core.QgsMapLayer
|
Layer to reproject; It can be a vector, raster or point cloud layer. |
required |
target_crs
|
typing.Optional[typing.Union[str, int, qgis.core.QgsCoordinateReferenceSystem]]
|
CRS to reproject the layer to. |
None
|
Returns:
| Type | Description |
|---|---|
QgsMapLayer
|
Reprojected layer |
Source code in pyqgis_wrapper/projection/crs_handler.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 | |