lutraconsulting / serval

QGIS plugin for setting raster pixel values
42 stars 12 forks source link

Python error when selecting XYZ, WMS layer #38

Closed nicogodet closed 2 years ago

nicogodet commented 2 years ago
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
nicogodet commented 2 years ago

https://github.com/lutraconsulting/serval/blob/5308032facb2a633052b798018ec589aad7999be/Serval/serval.py#L693-L695

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

does the trick

erpas commented 2 years ago

Thanks @nicogodet