I'm trying to get the total area for a reprojected layer made by number of features selected by clicking on a layer with PyQGIS, but when I use iface.activeLayer().selectedFeatures()
a list of QgsFeatures is returned, not a QgsVectorLayer, so I have to convert back again to QgsVectorLayer or add these features to a layer, but so far I haven't been able to find how to do this.
The code I've been using:
layer = iface.activeLayer().selectedFeatures()
parameter = {'INPUT': layer, 'TARGET_CRS': 'EPSG:32615','OUTPUT': 'memory:Reprojected'}
result = processing.run('native:reprojectlayer', parameter)
areatot = 0
for elem in result['OUTPUT'].getFeatures():
geom = elem.geometry()
areatot += geom.area()