mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-27 00:33:48 -05:00
If set, all geometries will be reprojected from their original coordinate reference system to the destination CRS while iterating over features. If a CRS has been set as the destination CRS, then the filterRect parameter should be specified in the same CRS as this destination CRS. Additionally, a callback function can be specified on the request to be called if a transform exception is encountered while iterating over features. This is designed to make it easier for scripts and plugins to correctly reproject layers in an efficient and robust way, instead of having to implement lots of repeated code themselves and potentially missing some of the important considerations which come with reprojecting geometries & bounding boxes. Now, if a script wants the features from a layer in a specific CRS, they can call: crs = QgsCoordinateReferenceSystem('epsg:4326') request = QgsFeatureRequest().setDestinationCrs(crs) for f in layer.getFeatures(reqeuest): print('geometry in 4326 is {}.format(f.geometry().exportToWkt()))