[GRASS-dev] v.rast.stats: NULL values for very small areas
Blumentrath, Stefan
Stefan.Blumentrath at nina.no
Wed Oct 7 01:40:27 PDT 2015
Hi,
What about a flag for checking if all polygon categories are present in the raster version of the vector map, and giving a warning if that is not the case.
That will take more time but makes output more reliable.
Maybe one can - in case of non-rasterized polygons/lines - edit the raster map by writing cats to cells containing centroids (or midpoints for lines)....
However, also then - in case of significant mismatch between map scale and resolution of the region - can cats be not present in the raster (if more than one centroid falls into a cell). That only indicates that the user either has to rethink settings, choose another approach (repeat the command for only the non-rasterized polygons) or ignore the issues...
Cheers
Stefan
-----Original Message-----
From: grass-dev-bounces at lists.osgeo.org [mailto:grass-dev-bounces at lists.osgeo.org] On Behalf Of Maris Nartiss
Sent: 7. oktober 2015 10:23
To: Moritz Lennert <mlennert at club.worldonline.be>
Cc: Martin Landa <landa.martin at gmail.com>; GRASS developers list <grass-dev at lists.osgeo.org>
Subject: Re: [GRASS-dev] v.rast.stats: NULL values for very small areas
2015-10-06 19:26 GMT+03:00 Moritz Lennert <mlennert at club.worldonline.be>:
>> I just wonder how to implement within Python script.
>
>
> Get areas of all polygons (or lenghts of lines) with v.to.db and then
> divide the features into those with areas above pixel size and those
> with areas below. Treat each set differently (i.e. the former as
> before, the latter by using v.what.rast - with the -p flag - to get
> the pixel value). As the updating of the table is done feature by
> feature anyhow, all you lose in terms of performance is the additional
> step of calculating areas/lengths of features.
>
First of all - v.rast.stats is not affected by the size of polygon but by its shape/location. It uses v.to.rast thus data will be provided if raster cell centre falls into vector polygon (no matter how small it could be). Thus theoretically it is possible to construct a large polygon that still gets NULL value.
Thus the discussion should be - should statistics be collected also for cells that only partially lie within the polygon. Raster cell is the smallest unit and it is homogeneous thus interpretation "collect data on all cells even if polygon just touches it" might seem to be a valid idea. Proposed solution with v.what.rast is not a solution as it will sample raster map at the location of centroid thus in case of polygon covering more than one cell, a value of one of cells will be provided.
Personally I tend to favour current behaviour. It could be a bit better documented as current documentation states: "The vector map will be rasterized according to the raster map resolution." It is correct but an extra explanation would be helpful like: "Stats are provided only for polygons covering raster cell centres (or whole raster cell area)."
Just my 0.02c,
Māris.
_______________________________________________
grass-dev mailing list
grass-dev at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev
More information about the grass-dev
mailing list