2

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

2

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()
    mc.setExtent(QgsRectangle(1523828.20697162207216024, 
                              1480456.77211040654219687, 
                              1528473.08268394041806459, 
                              1483372.55568987946026027))
    mc.refresh()

def saveProject():
    pass

def closeProject():
    pass

Your project settings could look like this.

enter image description here

This way only the specified extent will be loaded.

1
  • 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.