<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi devs</div><div><br></div><div>I face a (IMHO) an API limitation that I'm not sure is a limitation of a feature :)</div><div><br></div><div>I'm working adding SLD export for rasters as new feature and some stretching (QgsContrastEnhancement) should be mapped differently if the min/max values has been modified from the real min/max of the image.</div><div><br></div><div>This can be simply asked to the raster with QgsRasterLayer.statistic(<band number>). The main problem I'm faced is that if statistic is not present it is ALWAYS calculated.</div><div>This means that if we have big images or a remote one (e.g. COG) this would take long time!<br>I do not analysed any raster provider, but I suppose that min/max values can be estimated asking to raster metadata.</div><div><br></div><div>IMHO we can have an API like</div><div>QgsRasterLayer.estimatedStatistic(<band number>)<br></div><div>or</div><div>QgsRasterLayer.statistic(<band number>, estimated=false)<br></div><div><br></div><div>that can return metadata values if available.<br></div><div><br></div><div><div>The proposal is valid if there is no a method to get estimated statistic, but I could be wrong and that's the reason of this post.<br></div><br class="gmail-Apple-interchange-newline"></div><div><div dir="ltr" class="gmail_signature">Luigi Pirelli</div><div dir="ltr" class="gmail_signature"><br></div><div dir="ltr" class="gmail_signature">p.s. remember to come to <a href="http://2019.qgis.es">2019.qgis.es</a> ;) we'll open inscription next monday!<br><br>**************************************************************************************************<br>* LinkedIn: <a href="https://www.linkedin.com/in/luigipirelli" target="_blank">https://www.linkedin.com/in/luigipirelli</a><br>* Stackexchange: <a href="http://gis.stackexchange.com/users/19667/luigi-pirelli" target="_blank">http://gis.stackexchange.com/users/19667/luigi-pirelli</a><br>* GitHub: <a href="https://github.com/luipir" target="_blank">https://github.com/luipir</a><br>* Mastering QGIS 2nd Edition:<br>* <a href="https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition" target="_blank">https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition</a><br>* Hire me: <a href="http://goo.gl/BYRQKg" target="_blank">http://goo.gl/BYRQKg</a><br>**************************************************************************************************</div></div></div></div></div>