I am using QGIS 3.4 LTS on Kubuntu Bionic LTS. I am using several global datasets like NaturalEarth, HydroRIVERS etc. Loading all of them takes too much time and memory especially on my laptop.

I am mostly working in India area only. So I'd like to apply some settings in my project to tell QGIS to load features from within India only for performance reasons. It is acceptable to have it as a lat/lon extent constraint rather than clipping to a polygon.

There is existing advice on how to clip data to given polygons but I don't want to maintain separate shapefiles etc with clipped data. So I'd prefer to set it in the project using global upstream data.

How can I achieve this in QGIS?

This question may be the QGIS equivalent of Definition query to display only part of layer that overlaps with specific polygon using ArcGIS Desktop.

1 Answer 1


This can be achieved using Macros in QGIS project settings. Please update your project macros with something like this. In your case, you can use the extent of geographic bounding box of India.

from qgis.core import QgsRectangle
from qgis.utils import iface

def openProject():
    mc = iface.mapCanvas()

def saveProject():

def closeProject():

Your project settings could look like this.

enter image description here

This way only the specified extent will be loaded.

  • Thanks for this but what units are those values in? I even checked qgis.org/api/classQgsRectangle.html but it's not of much help. If I want from 5° to 40° N and 65° to 100° E then how should I write it?
    – jamadagni
    Jan 16, 2020 at 15:32

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.