1

How can I iterate a layer group with owslib in QGIS in a script? If is not possible, are there alternatives?

Here is a sample code of what I'm trying to achieve: 2,5,8 has 1 as parent.

from owslib.wms import WebMapService
wms = WebMapService('https://neo.sci.gsfc.nasa.gov/wms/wms', version='1.1.1')
list(wms.contents)) #prints wms layers,not the groups also [['MOD14A1_M_FIRE', 'MOD14A1_E_FIRE'...]
# the above is listing only the children not the parents
# I want to iterate also the parent with 0->1->[2,5,8] within a script
   
img = wms.getmap(layers=['1'], #this is not working bcs a parent obviously
                 srs='EPSG:6343',
                 bbox=(708542, 460329, 731172, 493289),
                 size=(100, 100),
                 format='image/tiff')

enter image description here enter image description here

2
  • Can you add a picture of how the structure of your content looks like? I checked this ows neowms.sci.gsfc.nasa.gov/wms/wms and there are layers which one can fetch them with your code block and RGB or greyscale which style to be chosen i.imgur.com/JvJERNJ.png
    – Nil
    Commented Jan 24, 2021 at 7:00
  • @Nil the issues isn't that the qgis isn't showing me the layers in WMS Data Source Manager, the issue i have is to iterate with the script through the layers group, and choose a group(all childrens) or a single layer(child) based on some filter, like in your example: imgur.com/a/iQSC36o
    – Alexis
    Commented Jan 24, 2021 at 9:15

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.