Calculation of Area using Python program in QGIS

Опубликовано: 15 Май 2026
на канале: MSR Geo Spatial Solutions
3,803
62

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))