[GRASS-user] percentage of class in raster within polygons

Hi,

I have to calculate the percentage of given class of a raster within the polygons given in a vector (a regular grid). Since I’m dealing with large files and operations repeated in a chain, i should be focusing on what is the optimal (fastest) option to do that. I could vectorize the raster and use v.overlay and v.to.db, or using v.rast.stats i can count out the number of cells (should i use number for that or sum?) and then divide per area of the grid. Any better idea?

Thank you in advance

···

Best regards,

Dr. Margherita DI LEO
Scientific / technical project officer

European Commission - DG JRC
Institute for Environment and Sustainability (IES)
Via Fermi, 2749
I-21027 Ispra (VA) - Italy - TP 261

Tel. +39 0332 78 3600
margherita.di-leo@jrc.ec.europa.eu

Disclaimer: The views expressed are purely those of the writer and may not in any circumstance be regarded as stating an official position of the European Commission.

I haven’t tested it, but the fastest way could be to rasterize your polygon layer (using the resolution of the input raster or higher resolution - make sure to assign an unique id to each grid cell before) and then use r.stats

r.stats -a -p input=rasterized_polygon,raster

Rgds,

Paulo

···

On Wed, Feb 11, 2015 at 12:15 PM, Margherita Di Leo <diregola@gmail.com> wrote:

Hi,

I have to calculate the percentage of given class of a raster within the polygons given in a vector (a regular grid). Since I’m dealing with large files and operations repeated in a chain, i should be focusing on what is the optimal (fastest) option to do that. I could vectorize the raster and use v.overlay and v.to.db, or using v.rast.stats i can count out the number of cells (should i use number for that or sum?) and then divide per area of the grid. Any better idea?

Thank you in advance

Best regards,

Dr. Margherita DI LEO
Scientific / technical project officer

European Commission - DG JRC
Institute for Environment and Sustainability (IES)
Via Fermi, 2749
I-21027 Ispra (VA) - Italy - TP 261

Tel. +39 0332 78 3600
margherita.di-leo@jrc.ec.europa.eu

Disclaimer: The views expressed are purely those of the writer and may not in any circumstance be regarded as stating an official position of the European Commission.


grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

how about,
v.rast.stats with number/sum option and then field calculations?
regards,
sotiris

On 02/11/2015 01:15 PM, Margherita Di Leo wrote:

Hi,

I have to calculate the percentage of given class of a raster within the
polygons given in a vector (a regular grid). Since I'm dealing with large
files and operations repeated in a chain, i should be focusing on what is
the optimal (fastest) option to do that. I could vectorize the raster and
use v.overlay and v.to.db, or using v.rast.stats i can count out the number
of cells (should i use number for that or sum?) and then divide per area
of the grid. Any better idea?

Thank you in advance

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user