2

I have a folder with ~100 QGIS-style files (.qml). Is it possible to tell QGIS that whenever I load a layer which has the same name as one of the .qml files apply that style instead of giving the layer a random color?

We have layers in each of our customers' folders, always with the same name (e.g. "Trees") so .qlr is not an option.

I know I can do it with a Python script, but I do not want to execute it every time I add a new layer. Maybe it is possible to trigger the script automatically everytime a layer is added?

4
  • 2
    Why not using Layer Definition file (.qlr) rather than .qml ? this seem more adequate for your situation (gis.stackexchange.com/questions/330532/…). In the meantime this (gis.stackexchange.com/questions/338626/…) could probably adapted to your current situation.
    – J.R
    Commented Jul 5, 2023 at 8:11
  • we have around 50 customers with the same basic datastructure. for example there is one file called "Trees.shp" in each customer's folder. whenever i open any custoomers "tree" file, i do not want to apply the style (which is for all customers the same) manually - so .qlr seems not to be the right choice for me. I'll check out the second link you provided!
    – sn1ks
    Commented Jul 5, 2023 at 8:29
  • 1
    With .qlr, you open the qlr file, you don't open the shapefile, the qlr references the shapefile, it's not a case of applying any style manually
    – nmtoken
    Commented Jul 5, 2023 at 9:07
  • 1
    @sn1ks You should provide these precision in your question by editing it. So yes it seem that adapting the script in the linked answer to automate thing bis the way to go in your case
    – J.R
    Commented Jul 5, 2023 at 9:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.