EnMAP-Box / enmap-box

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

[Import XYZ product] performance issue with scaled reflectance raster #1028

Open janzandr opened 2 hours ago

janzandr commented 2 hours ago

Discussed with @jakimowb and @danschef .

Imported sensor products store proper data gain/offset values for scaling the reflectance data into the 0 to 1 range. When visualizing such raster in QGIS/EnMAP-Box, very large default histograms are stored in the raster with 10 mio bins. This is slowing down raster handling/visualization. image

This is most likely a GDAL related bug, which should be reported. As a wordaround, we can just precalculate the histograms with reasonable bin counts and store into the raster.

for band_index in range(1, dataset.RasterCount + 1):
    band = dataset.GetRasterBand(band_index)
    min_val, max_val = band.ComputeRasterMinMax()
    histogram = band.GetHistogram(min=min_val, max=max_val, buckets=1000, approx_ok=False)
    band.SetDefaultHistogram(min_val, max_val, histogram,)
jakimowb commented 2 hours ago

Is this caused by gdal or QGIS?

janzandr commented 2 hours ago

Visualizing the raster in QGIS will trigger the creation of the histograms.

janzandr commented 2 hours ago

I will report it in the QGIS issue tracker. @rouault will hopefully take care of it ;-)

rouault commented 1 hour ago

@rouault will hopefully take care of it ;-)

I'm like everybody: I only work 25 hours / day... More seriously: the whole point of open source is that you can try fixing bug that annoy you, without being depend on the availability/willingness of someone else to do it for you.

janzandr commented 1 hour ago

Hi @rouault, we will fix this on our side (Python plugin) and hopefully, someone on the C++ side will also take care of it. We here, very value your past effords regarding improving raster integration in QGIS. Have a nice day, looking forward seeing you at one of the next QGIS conferences. All the best, Andreas.