[GRASS-user] How to list all unique pixel values (of a raster) covered by polygons (areas) for each polygon separately(?)

G. Allegri giohappy at gmail.com
Thu Jan 17 12:25:15 EST 2008


Just a rapid idea.
You could make just one rasterized map of your polygons and then
insert in a loop this, giving each pixel a unique category value:

r.mapcalc "MASK = if(raster=$i,1,null())"
with $1 the cat value (deriving from you original polygon)

and then run r.stats, which will work only for the un-masked pixels.

I don't have time to try this method, hope it helps.
GIovanni

2008/1/17, nikos.alexandris at felis.uni-freiburg.de
<nikos.alexandris at felis.uni-freiburg.de>:
> Salut Jose!
>
> This is what I am doing... and I only have 7 polygons - so
> it is ok.
>
> But if I have 50 polygons... I am not so sure how to script
> it to get (finally) a table with all pixels for each unique
> polygon for 2 different images of the same location (for
> raster MODIS year 2006 and then another of the same area
> MODIS 2007!).
>
> I want to run a regression with the pixel values... (pairs
> of 2006 and 2007 values).
>
> Thank you,
>
> Nikos.
>
>
>
> On Thu, 17 Jan 2008 16:42:31 +0000
>  "Jose Gomez-Dans" <jgomezdans at gmail.com> wrote:
> > On Jan 17, 2008 4:30 PM,
> > <nikos.alexandris at felis.uni-freiburg.de> wrote:
> >
> > > How can I get listed all unique pixel values enclosed
> > in
> > > each of the polygons I digitised (and for which the
> > univ.
> > > stats are calculated)?
> > >
> >
> > Can't you just rasterise your polygons, and use that as a
> > mask with
> > r.mapcalc? You can loop around in your shell. I tend to
> > do that with python,
> > but it's similar in GRASS. You can also try starspan.
> > Or.... <
> > http://grass.gdf-hannover.de/wiki/Aggregate_Values>
> >
> > Cheers,
> > Jose
> >
> >
> >
> > --
> > Centre for Terrestrial Carbon Dynamics
> > Department of Geography, University College London
> > Gower Street, London WC1E 6BT, UK
>
>
>                         .
>          Nikos Alexandris - Ph.D. Candidate
>                         .
>             Department of Remote Sensing
>                        and
>             Landscape Information Systems
>                      (FeLIS)
>                         .
>       Faculty of Forestry and Natural Environment
>           Albert-Ludwigs-University Freiburg
>                         .
>             Tel.  +49 (0) 761 203 3697
>             Fax.  +49 (0) 761 203 3701
>              Skype: Nikos.Alexandris
>                         .
>            Address: Tennenbacher str. 4
>               D-79106 Freiburg i. Br.
>                      Germany
>                         .
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>


More information about the grass-user mailing list