[GRASS-user] zonal statistics/metrics - beyond simple statistics

Stefan Blumentrath Stefan.Blumentrath at nina.no
Tue Apr 10 02:01:20 PDT 2018


Hei Bernardo,

Just for the record: I am currently working on something similar / related.

First of all I would like to improve speed of v.rast.stats for multiple inputs:
https://www.mail-archive.com/grass-dev@lists.osgeo.org/msg52562.html and 
https://trac.osgeo.org/grass/ticket/3523

Adding a functionality to "tabulate areas" or "count categories" is a next step I have in mind which I am working on in v.rast.bufferstats (will be a port of v.what.rast.buffer [1] to GRASS 7 / pygrass (with some enhancements)). Once I have a good solution there I would like to see if it can be moved to v.rast.stats. Support for dbf driver is however a challenge...

I will add my "work in progress" script to github, so you can have a look if you like.

Cheers
Stefan

1: https://grass.osgeo.org/grass64/manuals/addons/

-----Original Message-----
From: grass-user <grass-user-bounces at lists.osgeo.org> On Behalf Of Helmut Kudrnovsky
Sent: mandag 9. april 2018 23.19
To: grass-user at lists.osgeo.org
Subject: Re: [GRASS-user] zonal statistics/metrics - beyond simple statistics

Bernardo Santos wrote
> Dear GRASS list,
> I am developing a Python script to be able to calculate (virtually 
> any) metrics or statistics for zones/polygons in a vector - in analogy 
> to zonal statistics (such as v.rast.stats).The idea is that one can 
> calculate raster-based metrics (such as proportion of habitat, number 
> of patches, or any metric that can be formalized as a function that 
> takes some information from the input raster and returns a value) for 
> each polygon in the vector, and this is updated as a value in a newly 
> created column in the attribute table of this vector.
> Is there already anything like that (some addon/module) that I am 
> missing, just to avoid re-doing something already created?
> If not, what I am doing is to create a loop over all the features in a 
> vector, and for each one I zoom and use the polygon to define a mask 
> (using r.mask), so that the calculation of the selected metric is 
> performed only over that polygon, and this process is repeated.The 
> script allows one to calculate metrics/statistics for multiple raster 
> maps at once, and to incorporate other function for statistics also. 
> It may be found here:https://github.com/LEEClab/GeneralizedZonalStats
> 
> For small vectors this works nicely and I believe it has a great 
> potential. However, when I try to calculate metrics for a large 
> dataset (e.g. the Brazilian map of cities, with almost 6,000 polygons) 
> - and that is when the tool would be interesting -, the process of 
> creating each mask takes too long (387 steps), and the tool becomes kind of useless.
> Then I have two questions:- First, what drives the number of steps 
> GRASS takes to create a mask? Why it is very small for some maps but 
> very large for others? I quite don't understand that yet.- Do you 
> think of a easier or faster way of doing the same thing (instead of using masks)?
> v.rast.stats seems to use r.univar and the option 'zones' for doing 
> so, but then one gets restricted to the statistics calculated by this module.
> Any help or comment would be very welcome!
> Best,Bernardo Niebuhr
> _______________________________________________
> grass-user mailing list

> grass-user at .osgeo

> https://lists.osgeo.org/mailman/listinfo/grass-user

have look at

https://grass.osgeo.org/grass74/manuals/addons/v.habitat.dem.html

where I've coded some DEM derived stats and characteristics for polygones.




-----
best regards
Helmut
--
Sent from: http://osgeo-org.1560.x6.nabble.com/Grass-Users-f3884509.html
_______________________________________________
grass-user mailing list
grass-user at lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user


More information about the grass-user mailing list