EnMAP-Box / enmap-box

EnMAP-Box source code repository. See https://enmap-box.readthedocs.io for documentation
GNU General Public License v3.0
35 stars 16 forks source link

[RasterReader] add support for none-GDAL Rasters / generic QgsRasterDataProvider support #857

Open jakimowb opened 3 months ago

jakimowb commented 3 months ago

The RasterReader fails to read QgsRasterLayers that use other data provider than GDAL (which is the case for 6 of 7 standard QGIS QgsRasterDataProviders)

Supported QgsRasterDataProviders

How to reproduce:

from enmapboxprocessing.rasterreader import RasterReader
from enmapbox.testing import start_app
from qgis.core import QgsRasterLayer
from enmapbox.qgispluginsupport.qps.utils import rasterArray

app = start_app()

wcsUri = r'dpiMode=7&identifier=OneGDev:WesternMed-MCol&tilePixelRatio=0&url=https://ogcdev.bgs.ac.uk/geoserver/OneGDev/wcs?acceptversions%3D2.0.1'
lyr = QgsRasterLayer(wcsUri, 'WCS Example', providerType='wcs')

assert lyr.isValid()
data = rasterArray(lyr)
print(data.shape)
s = ""

# now we would expect the RasterReader reads without GDAL
reader = RasterReader(lyr, openWithGdal=False)

relates to #764

janzandr commented 3 months ago

Hi @jakimowb, currently, the RasterReader only supports GDAL raster.

If we want to, we can also support Web Coverage Service (WCS). So far, there was no need for it.

jakimowb commented 3 months ago

It's not only because of WCS. There are several other data providers, e.g. for virtual rasters. Also the spectral processing widget uses its own rasterdataprovider to avoid data redundancy.

jakimowb commented 3 months ago

If the RasterReader supports GDAL sources only, it should be better renamed.

However, I think it would be better if it's features present a true superset of features of a standard QgsRasterLayer. It should work with any rasterlayer instance, and provides additional options in case of GDAL rasterproviders.

janzandr commented 3 months ago

Yes, totally agree, but let's have a seperate Issue for each new provider, which we need/want to support.

jakimowb commented 3 months ago

I don't think it is necessary to create an issue for each single provider. The RasterReader just should work fine with any QgsRasterData provider. On top, it might add value in case of providers like gdal, e.g. by reading metadata from extra files. However, it should still work generically with any QgsRasterData interface.

janzandr commented 2 months ago

WMS provider should work now (see #865)

janzandr commented 2 months ago

@jakimowb, which provider should be implemented next? Anything urgent before the v3.14 release?

jakimowb commented 2 months ago

The RasterReader should generally accept all QgsRasterLayers/QgsRasterDataProviders.

I'll enhance (somewhen) the enmapbox.testing.TestObject to provide a set of rasterlayers with different providers. See #870

janzandr commented 2 months ago

Waiting for enmapbox.testing.TestObject enhancement.