I have over 400 layers, and I need to extract the extent information into a list.

Is there any way I can extract the extent for all 400 layers into a single file?

Copy and pasting one by one isn't practical.

  • 1
    To do an automation task this I think you should use PyQGIS.
    – PolyGeo
    Sep 2, 2019 at 21:33

1 Answer 1


A quick google on GIS Stack Exchange has the following resources:

Put those together with a simple csv write command using pyQGIS suggests the following as a first attempt:

with open ("outputfile.csv","w") as off:
    #get all map layers:
    layers = QgsProject.instance().mapLayers().values()
    #loop through layers 
    for layer in layers:
        #get extent of current layer
        ext = layer.extent()
        xmin = ext.xMinimum()
        xmax = ext.xMaximum()
        ymin = ext.yMinimum()
        ymax = ext.yMaximum()
        #write to csv file

Disclaimer: put together from code snippets and not tested. However this does give a quick idea of an initial method for further development.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.