I'm having an issue with QGIS not identifying all layers correctly.
In my project, I have a group named "Mapas" with the following structure:
Layers inside "Mapas":
localizacao_pl municipal_limits_ibge_pl.shp classificacao_climatica_koppen_pl.shp Groups inside "Mapas":
localizacao with the layers: localizacao_pl Google_Satellite_localizacao Clima with two subgroups: Mapa_clima_direito Mapa_clima_esquerdo Inside the Mapa_clima_direito and Mapa_clima_esquerdo subgroups, there are the following layers:
localizacao_pl municipal_limits_ibge_pl.shp classificacao_climatica_koppen_pl.shp
However, when I map layers, it does not show the correct number of layers:
all_layers = QgsProject.instance().mapLayers().values()
# Print names of all layers
for layer in all_layers:
print(layer.name())
123_localizacao_pl
123_localizacao_pl
123_localizacao_pl
758_classificacao_climatica_koppen_pl.shp
758_classificacao_climatica_koppen_pl.shp
758_municipal_limits_ibge_pl.shp
758_municipal_limits_ibge_pl.shp
Google_Satellite_localizacao
This issue is causing problems because:
I am creating a script to add layers automatically to the project root, then move them to the appropriate group and remove them from the root. This works until the "Localizacao" group is processed; once it enters the "Clima" group, the script does not delete layers from the root. It is not applying styles to all layers with the same name, only a few. How can I determine the cause of this issue?