2

I would like to create a plugin where I could use the values of a raster layer from the actual extent, to do some tricks.

For example if I have a raster which is a box [x,y,width,height] : [0,0,1000,1000], I zoom on it to see the AOI so my actual extent begin [50,50,100,100] (for example), how can I use it these values, without reloading the entire image ?

I would like to do really fast calcul (no reloading, no saving, just displaying with vector calcul => Instant on small area).

I can get the value of one pixel doing it like that :

layer = iface.mapCanvas().layers()[0]
extent = iface.mapCanvas().extent()

layer.dataProvider().identify(QgsPoint(extent.xMinimum(), extent.yMinimum()), QgsRaster.IdentifyFormatValue).results()[1]

Is that a way to us QgsRectangle on identify and not QgsPoint ? Because I would like to get the value of the extent rectangle and not from a point only, without doing a for loop of course to fill an array.

7
  • I believe that Zonal statistics does what you want and if not, you could perhaps improve that instead of creating your own plugin.
    – user30184
    Commented Oct 13, 2017 at 10:20
  • Actually Zonal statistics, don't get the values from an actual extent of a raster but from all the raster while Reloading it. That's why it take so much time to calcul on big TIF.
    – Lionel
    Commented Oct 13, 2017 at 10:36
  • I thought that it is analyzing just the areas which are as polygons on the polygon layer.
    – user30184
    Commented Oct 13, 2017 at 10:46
  • Nop, the extent is the coordinates of windows, of the datas you see on the QGIS window
    – Lionel
    Commented Oct 13, 2017 at 11:28
  • I just want to get the values which are display on the screen. If you zoom on a raster, on a small area, I want to use only these values, not all the datas of the raster.
    – Lionel
    Commented Oct 13, 2017 at 11:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.