lutraconsulting/serval

Python error when selecting XYZ, WMS layer

nicogodet opened this issue · 2 comments

AttributeError: 'NoneType' object has no attribute 'GetRasterBand' 
Traceback (most recent call last):
  File "C:\Users/godet/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Serval\serval.py", line 727, in set_active_raster
    if self.check_layer(layer):
  File "C:\Users/godet/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Serval\serval.py", line 698, in check_layer
    check_gdal_driver_create_option(layer),                 # GDAL driver has CREATE option
  File "C:\Users/godet/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\Serval\utils.py", line 99, in check_gdal_driver_create_option
    band = dataset.GetRasterBand(1)
AttributeError: 'NoneType' object has no attribute 'GetRasterBand'

Step to reproduce :

  1. add this XYZ layer : https://mt1.google.com/vt/lyrs=y&hl=fr&x={x}&y={y}&z={z}
  2. Select the layer in layer tree
  3. see python error

serval/Serval/serval.py

Lines 693 to 695 in 5308032

if layer.type() != QgsMapLayerType.RasterLayer:
return False
if all([

        if layer.type() != QgsMapLayerType.RasterLayer:
            return False
        if layer.providerType() != 'gdal':
            return False
        if all([

does the trick

erpas commented

Thanks @nicogodet