[QGIS-Developer] How to get estimated raster statistic without calc them?
Luigi Pirelli
luipir at gmail.com
Fri Jan 18 10:02:05 PST 2019
not shure if it's the same... not sure if the requests are for band
statistics or background image prefetch of an extended canvas view
(introduce 1y ago if I well remember)
you can simply check if bandSatatisti is available or triggered doing it
with (ir R is the QgsRasterLayer)
renderer = R.renderer()
renderer.hasStatistics(1) # True or Flase; 1 is the band number
stat = bandStatistics(1) # this would trigger remote reading if false step
before
bandStatistic is a QgsRasterInterface (e.g. the provider), so any provider
can implement statistic calc in different way...
Luigi Pirelli
**************************************************************************************************
* LinkedIn: https://www.linkedin.com/in/luigipirelli
* Stackexchange: http://gis.stackexchange.com/users/19667/luigi-pirelli
* GitHub: https://github.com/luipir
* Mastering QGIS 2nd Edition:
*
https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition
* Hire me: http://goo.gl/BYRQKg
**************************************************************************************************
On Fri, 18 Jan 2019 at 14:34, Richard Duivenvoorde <rdmailings at duif.net>
wrote:
> Hi Luigi,
>
> I cannot be of help, but I think I had exactly this problem then you,
> when there is a OGC-WCS service with for example a huge DEM/height model.
>
> And after that QGIS is requesting several times for one extent some
> portion of the data (while this server is very slow on this)
> I was thinking about a possibility to NOT do this everytime (or at least
> give an option to do it ONLY on the real data available already by QGIS).
>
> Does this fit your problem?
>
> Regards,
>
> Richard Duivenvoorde
>
> ps anybody willing to play with such a dem:
>
>
> https://geodata.nationaalgeoregister.nl/ahn3/wcs?request=GetCapabilities&service=wcs&version=1.1.2
>
> (epsg:28992)
>
> On 1/18/19 1:56 PM, Luigi Pirelli wrote:
> > Hi devs
> >
> > I face a (IMHO) an API limitation that I'm not sure is a limitation of a
> > feature :)
> >
> > 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.
> >
> > 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.
> > This means that if we have big images or a remote one (e.g. COG) this
> > would take long time!
> > I do not analysed any raster provider, but I suppose that min/max values
> > can be estimated asking to raster metadata.
> >
> > IMHO we can have an API like
> > QgsRasterLayer.estimatedStatistic(<band number>)
> > or
> > QgsRasterLayer.statistic(<band number>, estimated=false)
> >
> > that can return metadata values if available.
> >
> > 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.
> >
> > Luigi Pirelli
> >
> > p.s. remember to come to 2019.qgis.es <http://2019.qgis.es> ;) we'll
> > open inscription next monday!
> >
> >
> **************************************************************************************************
> > * LinkedIn: https://www.linkedin.com/in/luigipirelli
> > * Stackexchange: http://gis.stackexchange.com/users/19667/luigi-pirelli
> > * GitHub: https://github.com/luipir
> > * Mastering QGIS 2nd Edition:
> > *
> >
> https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition
> > * Hire me: http://goo.gl/BYRQKg
> >
> **************************************************************************************************
> >
> > _______________________________________________
> > QGIS-Developer mailing list
> > QGIS-Developer at lists.osgeo.org
> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> >
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190118/1beb9e9e/attachment.html>
More information about the QGIS-Developer
mailing list