15 YouTube views, likes subscribers in 10 minutes. Free!
Get Free YouTube Subscribers, Views and Likes

Calculation of Area using Python program in QGIS

Follow
MSR Geo Spatial Solutions

Hi Viewers,
From this video, you will know the process of calculation of geometry (area) of polygon features using python program in QGIS.
Find the code below:
d = QgsDistanceArea()
d.setEllipsoid('WGS84')
layer = iface.activeLayer()
features = layer.getFeatures()
for f in features:
geom = f.geometry()
name = f.attribute("Name")
print(name)
print("Area (sq.m):", d.measureArea(geom))
print("Area (km2):", d.convertAreaMeasurement(d.measureArea(geom), QgsUnitTypes.AreaSquareKilometers))
print("Perimeter(m):", d.measurePerimeter(geom))

posted by plaifeceapeto