Re: [Qgis-user] [QGIS-Developer] PSA: Don't update to Gnome 44!

2023-04-27 Thread Richard Duivenvoorde via QGIS-User

Ooh, tricky! Thanks Nyall for this heads up!

Was 44 already released actually?

As Debian testing/sid is now in something-freeze (and on 43).. I do not think 
it will enter 44 before release of Bookworm..?
So at least Debianista's are good untill that.

Reading the issue, I see it's about Qt5 AND Qt6, and there seems to be some 
work-around running applications in native Wayland mode (but in that QGIS has 
other issues...)

Hope this will be fixed soon...

Regards,

Richard

On 4/28/23 07:25, Nyall Dawson via QGIS-Developer wrote:

Hi lists,

Just a quick PSA: If you're using QGIS (or any Qt based app), I recommend 
avoiding an upgrade to any gnome 44 based distribution for now.

You'll get hit with this nasty bug: 
https://gitlab.gnome.org/GNOME/mutter/-/issues/2715 
 which breaks drag and 
drop functionality in all Qt applications. And in the process, basically makes QGIS 
unusable... 

You've been warned!

Nyall


___
QGIS-Developer mailing list
qgis-develo...@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


___
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


[Qgis-user] PSA: Don't update to Gnome 44!

2023-04-27 Thread Nyall Dawson via QGIS-User
Hi lists,

Just a quick PSA: If you're using QGIS (or any Qt based app), I recommend
avoiding an upgrade to any gnome 44 based distribution for now.

You'll get hit with this nasty bug:
https://gitlab.gnome.org/GNOME/mutter/-/issues/2715 which breaks drag and
drop functionality in all Qt applications. And in the process, basically
makes QGIS unusable... 

You've been warned!

Nyall
___
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


[Qgis-user] Fresh install of QGIS Server doesn't work as expected

2023-04-27 Thread Jeremy Garniaux via QGIS-User

Hi,

I'm trying to deploy QGIS Server on a Debian 11 VPS.
Following the doc (1)(2), I installed QGIS 3.30. Then I tested the 
install with


> /usr/lib/cgi-bin/qgis_mapserv.fcgi

Here's the output:

> $ /usr/lib/cgi-bin/qgis_mapserv.fcgi
> Application path not initialized
> Application path not initialized
> Application path not initialized
> Application path not initialized
> Warning 1: Unable to find driver ECW to unload from GDAL_SKIP 
environment variable.
> Warning 1: Unable to find driver ECW to unload from GDAL_SKIP 
environment variable.
> Warning 1: Unable to find driver JP2ECW to unload from GDAL_SKIP 
environment variable.

> "Loading native module /usr/lib/qgis/server/libdummy.so"
> "Loading native module /usr/lib/qgis/server/liblandingpage.so"
> "Loading native module /usr/lib/qgis/server/libwcs.so"
> "Loading native module /usr/lib/qgis/server/libwfs.so"
> "Loading native module /usr/lib/qgis/server/libwfs3.so"
> "Loading native module /usr/lib/qgis/server/libwms.so"
> "Loading native module /usr/lib/qgis/server/libwmts.so"
> Content-Length: 0
> Location: http:/index.json
> Server:  QGIS FCGI server - QGIS version 3.30.1-'s-Hertogenbosch
> Status:  302

It's not what I expected after reading the doc but I kept going anyway, 
uploaded my custom QGIS project to the server, set up Apache and 
scrupulously followed the doc. Then I checked the availability of QGIS 
Server with


> 
http://qgis.demo/cgi-bin/qgis_mapserv.fcgi?SERVICE=WMS=1.3.0=GetCapabilities


...but got a 404 error.

Any suggestion on what I'm doing wrong?

Thanks for your help.

Best regards,

Jeremy


(1) https://docs.qgis.org/3.28/en/docs/server_manual/getting_started.html
(2) https://qgis.org/en/site/forusers/alldownloads.html

--
Jeremy Garniaux
https://mapper.fr
https://mapstodon.space
___
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


Re: [Qgis-user] Shape file - Change "Polygon" to "Multipolygon"

2023-04-27 Thread Andrea Giudiceandrea via QGIS-User

Riccardo riccardopani at hotmail.com
Thu Apr 27 03:06:54 PDT 2023



I have shape file already created for a standard delivery.
The geometry type of this shape file is “Polygon” and I have to change it into 
“Multipolygon”.
Is it possible? And how can I change this property in a shape file already 
created without creating a new one?


Hi Riccardo,
if with "shape file" you are referring to the ESRI Shapefile format, 
then, as you can read in the "ESRI Shapefile Technical Description" [1], 
there is only one type of polygon layer (apart from the M and Z+M 
variants) in the ESRI Shapefile format: it is called Polygon in the 
format nomenclature and it can stores natively both multi-part and 
single-part (which are actually multipart with only 1 part) geometries.


An ESRI Shapefile Polygon layer is imported in QGIS (at least, for 
recent versions) as a "Polygon (MultiPolygon)" layer, i.e. a 
MultiPolygon layer, even if it does not contains any feature or if only 
contains geometries with only 1 part.


In QGIS, any geometry contained in an ESRI Shapefile Polygon layer is 
considered a MultiPolygon geometry: if it has only 1 part, it will be a 
MultiPolygon geometry with only one part; if it has more then 1 part, it 
will be a MultiPolygon with more than 1 part.


Is your "shape layer" an ESRI Shapefile layer? If yes, could you better 
explain why do you think the geometry type of this "shape file" is (non 
Multi) "Polygon". If not, could you please name the format of the layer?


Best regards.

Andrea Giudiceandrea

[1] 
https://www.esri.com/content/dam/esrisites/sitecore-archive/Files/Pdfs/library/whitepapers/pdfs/shapefile.pdf#page=12

___
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


Re: [QGIS-it-user] MagicWand in python Console

2023-04-27 Thread Andrea Giudiceandrea via QGIS-it-user

Il 27/04/2023 13:42, Giulio Fattori ha scritto:
Ho installato pip che non era presente, aggiornato pip, installato 
black, isort e autoprep8 e adesso funziona perfettamente

non capisco come mai non vengano installati di default


Il pacchetto python3-pip viene installato automaticamente quando si 
installano i pacchetti qgis-ltr-full o qgis-full o qgis-dev-full o 
qgis-ltr-full-free o qgis-dev-full-free


Comunque la funzionalità di Reformat Code è stata introdotta solo un 
mese fa ed è quindi disponibile solo nei pacchetti di sviluppo di QGIS e 
sarà disponibile solo a partire da QGIS 3.32. Gli sviluppatori che hanno 
introdotto tale funzionalità hanno comunque valutato che, essendo essa 
destinata ad altri sviluppatori, questi ultimi non dovrebbero avere 
difficoltà ad installare autonomamente i pacchetti.


Considera, peraltro, che mentre su Windows tramite OSGeo4W che è gestita 
da sviluppatori core di QGIS, è possibile richiedere (sempre tramite 
https://trac.osgeo.org/osgeo4w/ ) che tali pacchetti vengano resi 
disponibili ed eventualmente automaticamente installati, in altri 
sistemi, come quelli Ubuntu Linux, QGIS usa di norma l'installazione 
Python di sistema con i relativi moduli e non è quindi possibile per gli 
sviluppatori di QGIS intervenire nell'installazione di tali moduli che 
quindi devono essere installati manualmente.


A presto.

Andrea
___
QGIS-it-user mailing list
QGIS-it-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/qgis-it-user


Re: [QGIS-it-user] MagicWand in python Console

2023-04-27 Thread Giulio Fattori
Ho installato pip che non era presente, aggiornato pip, installato 
black, isort e autoprep8 e adesso funziona perfettamente

non capisco come mai non vengano installati di default
Grazie ancora una volta
a Presto
Giulio

Il 27/04/2023 13:14, Andrea Giudiceandrea via QGIS-it-user ha scritto:

Il 27/04/2023 06:22, Giulio ha scritto:

Buongiorno
Non sono presenti e non vengono installati da osgeo, parrebbero 
mancare nel repositori


Ciao Giulio,
mi pare che il modulo python autopep8 sia disponibile in OSGeo4W: il 
nome del pacchetto da installare tramite Setup è python3-autopep8


Il modulo isort invece manca in OSGeo4W. Potrebbe esserne richiesto 
l'inserimento creando un ticket in https://trac.osgeo.org/osgeo4w/


I moduli Python dovrebbero poter essere comunque installati 
indipendentemente da OSGeo4W, utilizzando il comando pip che li 
installa dal repository ufficiale PyPI.
Per installare un modulo dal repository ufficiale PyPI nella versione 
di Python usata da QGIS su Windows installato tramite OSGeo4W, 
dovrebbe essere sufficiente quindi eseguire il seguente comando nella 
OSGeo4W Shell:


python -m pip install nome_modulo_python

A presto.

Andrea
___
QGIS-it-user mailing list
QGIS-it-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/qgis-it-user



___
QGIS-it-user mailing list
QGIS-it-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/qgis-it-user


Re: [QGIS-it-user] MagicWand in python Console

2023-04-27 Thread Andrea Giudiceandrea via QGIS-it-user

Il 27/04/2023 06:22, Giulio ha scritto:

Buongiorno
Non sono presenti e non vengono installati da osgeo, parrebbero mancare 
nel repositori


Ciao Giulio,
mi pare che il modulo python autopep8 sia disponibile in OSGeo4W: il 
nome del pacchetto da installare tramite Setup è python3-autopep8


Il modulo isort invece manca in OSGeo4W. Potrebbe esserne richiesto 
l'inserimento creando un ticket in https://trac.osgeo.org/osgeo4w/


I moduli Python dovrebbero poter essere comunque installati 
indipendentemente da OSGeo4W, utilizzando il comando pip che li installa 
dal repository ufficiale PyPI.
Per installare un modulo dal repository ufficiale PyPI nella versione di 
Python usata da QGIS su Windows installato tramite OSGeo4W, dovrebbe 
essere sufficiente quindi eseguire il seguente comando nella OSGeo4W Shell:


python -m pip install nome_modulo_python

A presto.

Andrea
___
QGIS-it-user mailing list
QGIS-it-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/qgis-it-user


Re: [Qgis-user] Shape file - Change "Polygon" to "Multipolygon"

2023-04-27 Thread Bernhard Ströbl via QGIS-User
If I remember it right there is no difference in the file itself. A shape file 
can digest single and multi geometries without changing its format. Are your 
polygons single or multi? If they are single it says single. Try adding some 
multi polygons and look what happens.
Bernhard

> Riccardo via QGIS-User  hat am 27.04.2023 12:06 
> CEST geschrieben:
> 
>  
> Good morning to all,
> 
> 
> I'm here again because I need another hint.
> 
> 
> I have shape file already created for a standard delivery.
> 
> 
> The geometry type of this shape file is “Polygon” and I have to change it 
> into “Multipolygon”.
> 
> 
> Is it possible? And how can I change this property in a shape file already 
> created without creating a new one?
> 
> 
> Many many thanks!
> 
> 
> Best Regards.
> 
> 
> Riccardo.
> 
> ___
> QGIS-User mailing list
> QGIS-User@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
___
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


Re: [Qgis-user] Shape file - Change "Polygon" to "Multipolygon"

2023-04-27 Thread Richard McDonnell via QGIS-User
Hi Riccardo,
You can use the Processing Toolbox, so a search for Promote to multipart.
This will create a new layer, which will have all geometries converted to 
multipart.
Kind Regards,

Richard





--
Richard McDonnell MSc GIS, FME Certified Professional
FRM Data Management

--
Oifig na nOibreacha Poibl?
Office of Public Works

Sr?id Jonathan Swift, Baile ?tha Troim, Co na M?, C15 NX36
Jonathan Swift Street, Trim, Co Meath, C15 NX36
--
M +353 87 688 5964 T +353 46 942 2409
https://gov.ie/opw

--
To send me files larger than 30MB, please use the link below 
https://filetransfer.opw.ie/filedrop/richard.mcdonn...@opw.ie

Email Disclaimer: 
https://www.gov.ie/en/organisation-information/439daf-email-disclaimer/

--
MSc GIS, FME Certified Professional

--
Oifig na nOibreacha Poibl?
Office of Public Works

Sr?id Jonathan Swift, Baile ?tha Troim, Co na M?, C15 NX36
Jonathan Swift Street, Trim, Co Meath, C15 NX36
--
M +353 87 688 5964 T +353 46 942 2409
https://https://gov.ie/opw

--
Email Disclaimer: 
https://www.gov.ie/en/organisation-information/439daf-email-disclaimer/
From: QGIS-User  On Behalf Of Riccardo via 
QGIS-User
Sent: 27 April 2023 11:07
To: qgis-user@lists.osgeo.org
Subject: [Qgis-user] Shape file - Change "Polygon" to "Multipolygon"

Good morning to all,



I'm here again because I need another hint.



I have shape file already created for a standard delivery.



The geometry type of this shape file is "Polygon" and I have to change it into 
"Multipolygon".



Is it possible? And how can I change this property in a shape file already 
created without creating a new one?



Many many thanks!



Best Regards.



Riccardo.

___
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


[Qgis-user] Shape file - Change "Polygon" to "Multipolygon"

2023-04-27 Thread Riccardo via QGIS-User
Good morning to all,


I'm here again because I need another hint.


I have shape file already created for a standard delivery.


The geometry type of this shape file is “Polygon” and I have to change it into 
“Multipolygon”.


Is it possible? And how can I change this property in a shape file already 
created without creating a new one?


Many many thanks!


Best Regards.


Riccardo.

___
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


Re: [Qgis-user] Opening GEOTIFF file in QGIS support request

2023-04-27 Thread Richard McDonnell via QGIS-User
Hi Gino,
From the screengrab you forwarded to me, I am inclined to agree with Richard. 
The data appears to be looking fine. You, as Richard said should probably use 
background mapping to verify the location but besides that it looks fine.

I have been on the Global Wind Atlas website, and looked at some of their 
documentation. The data appears to be provided at a resolution of 250m (you can 
verify this in the properties) which is why, when zoomed in it appears 
pixelated. You will need to style it to make it look similar to how it's 
displayed online.
Also note, that on the website the data stops being displayed beyond a certain 
zoom level, this is to prevent issues like that you are experiencing.
I hope that clarifies things.
Regard's,

Richard




——
Richard McDonnell MSc GIS, FME Certified Professional
FRM Data Management

——
Oifig na nOibreacha Poiblí
Office of Public Works

Sráid Jonathan Swift, Baile Átha Troim, Co na Mí, C15 NX36
Jonathan Swift Street, Trim, Co Meath, C15 NX36
——
M +353 87 688 5964   T +353 46 942 2409
https://gov.ie/opw

——
To send me files larger than 30MB, please use the link below 
https://filetransfer.opw.ie/filedrop/richard.mcdonn...@opw.ie

Email Disclaimer: 
https://www.gov.ie/en/organisation-information/439daf-email-disclaimer/



——
Richard McDonnell MSc GIS, FME Certified Professional
FRM Data Management

——
Oifig na nOibreacha Poiblí
Office of Public Works

Sráid Jonathan Swift, Baile Átha Troim, Co na Mí, C15 NX36
Jonathan Swift Street, Trim, Co Meath, C15 NX36
——
M +353 87 688 5964   T +353 46 942 2409
https://www.opw.ie

——
To send me files larger than 30MB, please use the link below 
https://filetransfer.opw.ie/filedrop/richard.mcdonn...@opw.ie

Email Disclaimer: https://www.opw.ie/en/disclaimer/
> -Original Message-
> From: QGIS-User  On Behalf Of Richard
> Duivenvoorde via QGIS-User
> Sent: 27 April 2023 08:51
> To: ginol...@aol.com; Qgis-user@lists.osgeo.org
> Subject: Re: [Qgis-user] Opening GEOTIFF file in QGIS support request
>
> Hi Gino (please also keep the mailing list into the loop :-) ),
>
> What I see in your screenshot looks fine?
> I see you loaded a project in EPSG:4326 (lower right corner), and you data is
> apparently also fine, as I see coordinates 32/-116 (northern Mexico, or
> southern California?).
> This is not what you supposed to see? Raster data (unlike aerials etc) are
> squares, with one or more data value's for every square. Which historically is
> shown in a white to black styling (as you can see).
> You can put the OpenStreetMap beneath it, to have more reference (and an
> idea about the size/precision of your data)?
>
> About ogrinfo.. sorry I meant gdalinfo this is a commandline too (also in the
> QGIS install of Windows), which shows information about gis-data (gdalinfo
> for rasters, ogrinfo for vector)..
>
> Or am I missing your point?
> Can you share you download url from the Wind Atlas? (I see they have a lot
> of types of data). And as asked: what were you hoping to see?
>
> Regards,
>
> Richard Duivenvoorde
>
> On 4/26/23 21:31, ginol...@aol.com wrote:
> > Hi Richard,
> > Thank you for your reply. It looks like I’m actually able to open the file;
> however, I’m not seeing any GIS-data. Yes, it’s a GEOTIFF file. There is 
> annual
> wind energy production sample test data in the file but after opening it in
> QGIS what I see is just the screenshot below. Could this be due to an error in
> creating the file?  For “output of ‘ogrinfo” do you mean the file name? It’s
> “gwa3_hh100m_tl10_FLH_m0_582qxe1h.tif”. This is a file download from
> Global Wind Atlas.
> > Screen Shot 2023-04-26 at 12.03.55 PM.png
> >
> > Still not quite sure what I’m doing wrong :/ Kind regards, Gino
> >
> > -Original Message-
> > From: Richard Duivenvoorde via QGIS-User 
> > To: qgis-user@lists.osgeo.org
> > Cc: Qgis-user@lists.osgeo.org 
> > Sent: Tue, Apr 25, 2023 7:44 pm
> > Subject: Re: [Qgis-user] Opening GEOTIFF file in QGIS support request
> >
> > Hi GIno,
> >
> > QGIS should 'just show/open/ geotiff's fine.
> >
> > Can you open the geotiff in another viewer?
> > If not, or uncertain, are you sure it is a GEO-tiff (that is it contains 
> > the spatial
> info?) and not a 'normal tiff'?
> > If so: can you provide the output of 'ogrinfo ? This should show
> you info about the CRS/bbos/scale etc...
> >
> > Is the CRS (Coordinate Projection System / 'projection') of your tiff set to
> the right value (comparted to your other layers or project crs)?
> >
> > Regards,
> >
> > Richard Duienvoorde
> >
> > On 4/25/23 21:53, Gino via QGIS-User wrote:
> >  > Hello,
> >  > Good afternoon. Just wanted to send an email to request advice on
> opening a GEOTIFF file in QGIS. I'm trying to open a .tif file with QGIS;
> however, unable to view the data and not sure why. Please let me know
> best way to view this file type in QGIS.
> >  > Thank you,
> >  > Gino
> >  >
> >  > ___
> >  > QGIS-User mailing list

Re: [Qgis-user] Opening GEOTIFF file in QGIS support request

2023-04-27 Thread Richard Duivenvoorde via QGIS-User

Hi Gino (please also keep the mailing list into the loop :-) ),

What I see in your screenshot looks fine?
I see you loaded a project in EPSG:4326 (lower right corner), and you data is 
apparently also fine, as I see coordinates 32/-116 (northern Mexico, or 
southern California?).
This is not what you supposed to see? Raster data (unlike aerials etc) are 
squares, with one or more data value's for every square. Which historically is 
shown in a white to black styling (as you can see).
You can put the OpenStreetMap beneath it, to have more reference (and an idea 
about the size/precision of your data)?

About ogrinfo.. sorry I meant gdalinfo this is a commandline too (also in the 
QGIS install of Windows), which shows information about gis-data (gdalinfo for 
rasters, ogrinfo for vector)..

Or am I missing your point?
Can you share you download url from the Wind Atlas? (I see they have a lot of 
types of data). And as asked: what were you hoping to see?

Regards,

Richard Duivenvoorde

On 4/26/23 21:31, ginol...@aol.com wrote:

Hi Richard,
Thank you for your reply. It looks like I’m actually able to open the file; 
however, I’m not seeing any GIS-data. Yes, it’s a GEOTIFF file. There is annual 
wind energy production sample test data in the file but after opening it in 
QGIS what I see is just the screenshot below. Could this be due to an error in 
creating the file?  For “output of ‘ogrinfo” do you mean the file name? It’s 
“gwa3_hh100m_tl10_FLH_m0_582qxe1h.tif”. This is a file download from Global 
Wind Atlas.
Screen Shot 2023-04-26 at 12.03.55 PM.png

Still not quite sure what I’m doing wrong :/
Kind regards,
Gino

-Original Message-
From: Richard Duivenvoorde via QGIS-User 
To: qgis-user@lists.osgeo.org
Cc: Qgis-user@lists.osgeo.org 
Sent: Tue, Apr 25, 2023 7:44 pm
Subject: Re: [Qgis-user] Opening GEOTIFF file in QGIS support request

Hi GIno,

QGIS should 'just show/open/ geotiff's fine.

Can you open the geotiff in another viewer?
If not, or uncertain, are you sure it is a GEO-tiff (that is it contains the 
spatial info?) and not a 'normal tiff'?
If so: can you provide the output of 'ogrinfo ? This should show you 
info about the CRS/bbos/scale etc...

Is the CRS (Coordinate Projection System / 'projection') of your tiff set to 
the right value (comparted to your other layers or project crs)?

Regards,

Richard Duienvoorde

On 4/25/23 21:53, Gino via QGIS-User wrote:
 > Hello,
 > Good afternoon. Just wanted to send an email to request advice on opening a 
GEOTIFF file in QGIS. I'm trying to open a .tif file with QGIS; however, unable to 
view the data and not sure why. Please let me know best way to view this file type 
in QGIS.
 > Thank you,
 > Gino
 >
 > ___
 > QGIS-User mailing list
 > QGIS-User@lists.osgeo.org 
 > List info: https://lists.osgeo.org/mailman/listinfo/qgis-user 

 > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user 


___
QGIS-User mailing list
QGIS-User@lists.osgeo.org 
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user 

Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user 



___
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user


Re: [Qgis-user] PyQGIS to set masked symbol layer and mask source in ver. 3.30

2023-04-27 Thread Anne B. Nilsen via QGIS-User
Thanks!

Not sure if I do this the best way (I'm not a programmer nor a pyQGIS-expert)...
I ended up with adding two procedures and changing the code-line for setting 
the mask () accordingly:

def get_symbollayer(layer, ruleId, symbollayer_ids):
"""
Returns the symbol layer according to given layer, ruleId (None if no rule) 
and the path
to symbol layer id (for instance [0, 1])
"""
renderer = layer.renderer()
symbol = None
if renderer.type() == "categorizedSymbol":
i = renderer.categoryIndexForValue(ruleId)
cat = renderer.categories()[i]
symbol = cat.symbol()
elif renderer.type() == "singleSymbol":
symbol = renderer.symbol()

symbollayer = symbol.symbolLayer(symbollayer_ids[0])
for i in range(1, len(symbollayer_ids)):
symbol = symbollayer.subSymbol()
symbollayer = symbol.symbolLayer(symbollayer_ids[i])

return symbollayer

def get_symbollayer_ref(layer, ruleId, symbollayer_ids):
   """
   Returns the symbol layer according to given layer, ruleId (None if no 
rule) and the path
   to symbol layer id (for instance [0, 1])
   """
   symbollayer = get_symbollayer(layer, ruleId, symbollayer_ids)
   return QgsSymbolLayerReference(layer.id(), symbollayer.id())
...
fileName = "./gpkg/karplantehoyder.gpkg"
layer = QgsVectorLayer(fileName, "hoyder", "ogr")
layer.loadNamedStyle('./qml/n5hoyder.qml')  # Load qml
QgsProject.instance().addMapLayer(layer, False) # Add layer False to be able
root.insertLayer(4,layer)   # to specify a custom position
label_settings = layer.labeling().settings()# Get current settings of the 
layer
text_format = label_settings.format()   # Get text format of the 
settings
text_format.mask().setMaskedSymbolLayers([get_symbollayer_ref(layer,"",[0])])  
# set masked symbol layers 
...

It woks, but is this the most convenient way to do it?

It seems to me like label masking information is not stored in the qml-file?
Is there a good reason for that?

Kind regards
Anne

-Opprinnelig melding-
Fra: Julien Cabieces 
Sendt: onsdag 26. april 2023 18:02
Til: Anne B. Nilsen 
Kopi: qgis-user@lists.osgeo.org
Emne: Re: [Qgis-user] PyQGIS to set masked symbol layer and mask source in ver. 
3.30


Hi,

I changed the way we referenced symbol layer to make it more simple and robust. 
Now, symbol layer have a generated unique id so it's easier to reference each 
of them (instead of a path of indices in the symbol layers tree before).

I see 2 solutions here:

1. You keep your old references and call
QgsProjectFileTransform.fixOldSymbolLayerReferences() on your layers

2. You change the way you create the references. here[0] is an example on how 
you can create QgsSymbolLayerReference.

I would favor solution 2 because you wouldn't rely on deprecated method and so 
you would be more future proof for when we eventually drop these methods.

Regards,
Julien

[0] 
https://github.com/qgis/QGIS/pull/50786/files#diff-c7f779c945b0e9c401ddb964691ec0d6a07c6c3fcfca0e3db146f97aec2d17e2R177

> Thanks to the answer to this post
> https://gis.stackexchange.com/questions/447362/pyqgis-to-set-masked-sy
> mbol-layer-and-mask-source
>
> I managed to set the mask layer in QGIS version 3.28.
>
>
>
> The code is not working In ver. 3.30 due to a change in the 
> QgsSymbolLayerReference class.
>
> However I’m not able to change the original code so it fits with the
> new specification
>
>
>
> I just don’t understand how to set the input parameters to fulfil the
> requirements in
> https://qgis.org/pyqgis/3.30/core/QgsSymbolLayerReference.html#qgis.co
> re.QgsSymbolLayerReference
>
>
>
> # Set masked symbol layers :  setMaskedSymbolLayers(self,
> maskedLayers: Iterable[QgsSymbolLayerReference])
>
>
>
> fileName = "./gpkg/karplantehoyder.gpkg"
>
> layer = QgsVectorLayer(fileName, "hoyder", "ogr")
>
> layer.loadNamedStyle('./qml/n5hoyder.qml')  # Load qml
>
> QgsProject.instance().addMapLayer(layer, False) # Add layer False to
> be able
>
> root.insertLayer(4,layer)   # to specify a custom position
>
> label_settings = layer.labeling().settings()# Get current settings of the 
> layer
>
> text_format = label_settings.format()   # Get text format of the 
> settings
>
>
>
> # old code (working in 3.28)
>
> #
> text_format.mask().setMaskedSymbolLayers([QgsSymbolLayerReference(laye
> r.id(), QgsSymbolLayerId("", 0))])  # set masked symbol layers *
>
>
>
> # -- New code
>
> linesymbol = QgsLineSymbol()
>
> lyr = linesymbol.symbolLayer(0) # Trying to get the id of the 
> line layer (hoyder)
>
> text_format.mask().setMaskedSymbolLayers([layer.id(), lyr.id()])  #
> set masked symbol layers – not working
>
> # --
>
>
>
> label_settings.setFormat(text_format)   # set format
>
> layer.labeling().setSettings(label_settings)# set settings
>
> layer.saveStyleToDatabase(layer.name(),'style n5hoyder',True,'')  #
> Save 

Re: [Qgis-user] setting map scale

2023-04-27 Thread Lester Anderson via QGIS-User
Thanks for the update and workaround for the problem.

On Wed, 26 Apr 2023 at 23:11, Andrea Giudiceandrea via QGIS-User <
qgis-user@lists.osgeo.org> wrote:

> > Lester Anderson arctica1963 at gmail.com
> > Wed Apr 26 08:29:04 PDT 2023
>
> > Not sure if this is a bug, but when trying to select the map scale from
> the
> > status bar (1) It is not expanded to see properly and (2) Clicking the
> down
> > button causes QGIS to crash.
> >
> > Issue: Version 3.30.1
>
>
> Hi Lester,
> the bug that caused the crash has been reported several times [1] and
> has been already fixed after various attempts [2].
>
> The fixes will land in the upcoming QGIS 3.30.2 release.
>
> In the meantime, you can workaround the issue even in QGIS 3.30.1 by
> going to "Settings->Options..." -> "Map Tools" -> "Predefined Scales"
> and click on the "Reset to default scales" button in order to restore
> the predefined scales, populate the map scale listbox and avoid the crash.
>
> Best regards.
>
> Andrea
>
>
> [1] see e.g. https://github.com/qgis/QGIS/issues/52383
> [2] https://github.com/qgis/QGIS/pull/52427 ,
> https://github.com/qgis/QGIS/pull/52414 ,
> https://github.com/qgis/QGIS/pull/52511 ,
> https://github.com/qgis/QGIS/pull/52580
> ___
> QGIS-User mailing list
> QGIS-User@lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>
___
QGIS-User mailing list
QGIS-User@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user