[QGIS-Developer] PyQGIS zoom to layer not working

Frank Broniewski broniewski at a-a.lu
Tue Aug 8 22:49:30 PDT 2023


Hello all,

I just wanted to return to my problem and show my solution. Like I already said, I tried back and forth, to no avail. Like I already described, zoom to layer never worked, and I still believe my earlier observation is true, that loading multiple layers at once changes the map extent everytime a layer gets loaded/added.

What helped in the end was this single line of code, between the layer loading code and the final zoom to layer code ...

        # wait for application to process pending tasks
        QCoreApplication.processEvents()

Maybe this is helpful for others as well.

Have a nice day,
Frank


-----Ursprüngliche Nachricht-----
Von: QGIS-Developer <qgis-developer-bounces at lists.osgeo.org> Im Auftrag von Frank Broniewski via QGIS-Developer
Gesendet: Donnerstag, 22. Juni 2023 10:56
An: rdmailings at duif.net; qgis-developer at lists.osgeo.org
Betreff: Re: [QGIS-Developer] PyQGIS zoom to layer not working

Hey Richard,

thanks for the good wishes! I feel, I completely jinxed it 😃. I will continue to investigate, as soon as I find a solution, I'll post it here ...

-----Ursprüngliche Nachricht-----
Von: Richard Duivenvoorde <rdmailings at duif.net> 
Gesendet: Dienstag, 20. Juni 2023 15:33
An: Frank Broniewski <broniewski at a-a.lu>; qgis-developer at lists.osgeo.org
Betreff: Re: AW: [QGIS-Developer] PyQGIS zoom to layer not working

On 6/20/23 14:56, Frank Broniewski wrote:
> I did set the QGIS default CRS to 2169 in the options, but this did not help unfortunately.

Mmm, that should work:

Settings / CRS and Transforms/ CRS for projects / Use a default CRS AND I would maybe also set the CRS for layer to epsg:2169

Another option is to create a 'Default Project' (empty, BUT crs set to epsg:2169) Settings / General / Set Current Project As Default and Checkbox 'Create new project from default project'

fiddling with those I'm pretty sure it should be possible to start QGIS in the right crs..

Suc6

Richard Duivenvoorde
_______________________________________________
QGIS-Developer mailing list
QGIS-Developer at lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


More information about the QGIS-Developer mailing list