My QGIS Atlas uses a fixed map canvas size and a fixed scale. The atlas generation shapefile has polygons in a steady interval. Therefore my maps do have an overlap area. My aim is to calculate said overlap. The intial idea was to get the coordinates of the map canvas extent and form a polygon from that. Now I want to erase this polygon from the $currentfeature polygon and this should be my overlap area. My current non-working and only pseudo code is like this:

from qgis.core import*
from qgis.gui import*
from qgis.utils import iface

@qgsfunction(args=0, group='Custom', usesgeometry=True)
def mapExtent(value1, feature, parent):
  bb = iface.mapCanvas().extent()
  gPolygon = QgsGeometry.fromPolygon(bb)
  clipstuff = clip(gPolygon, $currentfeature)
  overlap = $area(clipstuff)
  return overlap

The result should be shown in a label inside the atlas. I am not so good at coding.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.