[Qgis-user] Themes, visibility, layout, report, atlas and Layer ID vs Layer name

Sebastian Gutwein bas at rdgland.com
Thu Aug 19 12:24:50 PDT 2021


Jesahel,
This may be something you already do and I don't know if this would save
you any time but I often set up project variables in situations where I am
using a layer across many expressions or layouts.
Project>Properties>Variables
For example when I am referencing a DEM in expression over and over I
create a variable DEM and set to to the layer ID e.g.
'DEM_d44338fa_1bf5_4ea6_b58e_7489ea8b28a8' and then in my expression
reference @DEM in my expressions. While it is still a little annoying to
have to change the variable when I change the DEM I only have to change it
in one place.
-Bas

On Thu, Aug 19, 2021 at 2:23 PM Charles Dixon-Paver <charles at kartoza.com>
wrote:

> I would imagine there are just far too many projects and use cases where
> the same layer name is used for multiple layers. Saving and loading themes
> etc is a feature request I imagine. Copying styles between layers is
> supported (and you can save style and layer definitions). I imagine most
> issues can be resolved by just using an expression based id wherever
> possible, with something like this:
>
> QgsProject.instance().mapLayersByName('World Map')[0].id()
>
> On Thu, 19 Aug 2021 at 17:15, Jésahel Benoist <djes1975 at gmail.com> wrote:
>
>> Hello all,
>>
>> QGIS is now my favorite everyday tool. Anyway, there's something that is
>> a real pain in the ass, the choice to use layer ID instead of layer name in
>> layouts/reports/atlas/themes.
>>
>> First, let me explain that I have a lot of layers so I'm using groups, I
>> import/export needed groups with layers definition files and I'm often
>> using the name to track the versions between projects.
>>
>> At this stage, one bad thing is that deleting a layer and reloading is
>> changing its ID and so... All layouts/reports/atlas need to be corrected.
>> So I'm not deleting anymore groups/layers but instead have more dedicated
>> projects, and I have created some scripts and plugins to alter existing
>> layers, and loads/saves styles in DB. Fine but not easy for everybody and
>> needs to correct more projects when needed.
>>
>> Today I discovered that themes are also based on layers ID... But there
>> isn't any way to load/save themes configuration. How to know what was the
>> theme configuration before a change ? Only by peeking around in the project
>> file or some python. But even with a save/load feature, when a modification
>> occurs, all projects need to be corrected.
>>
>> Well, as you can see, for some years that I've been working with QGIS,
>> its use of the layer ID instead of layer name is clearly the most annoying
>> thing in this great software. I think that is also a reason for some
>> features not to be created.
>>
>> I imagine that this is low level and needs a lot of modifications so I'm
>> not asking for a change now. But could a discussion about this be initiated
>> ?
>>
>> Best regards to all,
>>
>> Jésahel
>>
>> _______________________________________________
>> Qgis-user mailing list
>> Qgis-user at 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 at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20210819/135db6bd/attachment.html>


More information about the Qgis-user mailing list