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:
> 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@.osgeo


have look at

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

best regards
Sent from:
grass-user mailing list

Reply via email to