[GRASS-stats] Raster maps from GRASS to R and back to GRASS?

Dylan Beaudette debeaudette at ucdavis.edu
Tue Apr 14 13:33:27 EDT 2009


On Tuesday 14 April 2009, Nikos Alexandris wrote:
> Nikos:
> > > > > What I actually do is nothing but a PCA on a combination of
> > > > > different bands. The fact is that bands a, b, c are of equal
> > > > > "length" in R and have _more_ non-NULLs than bands d, e, f.
>
> Dylan:
> > > > I think that you are going to have to maintain a band-wise null mask
> > > > in R, as opposed to a single null mask for the entire set of bands.
>
> [...]
>
> > An idea on how to apply this function:
> >
> > # load data
> > # extract an NA mask using complete.cases
> > # do something like prcomp()
> >
> > # assign back to original data
> > x.df$pca_1[x.na_mask] <-  predict(p)[,1]
> >
> > This would of course be done the the @data slot on an sp object. Thanks
> > to Roger for this slick approach.
> >
> > How about that!?
>
> Very helpful Dylan. I am learning a lot, as usual. However, no-matter
> what I try to do with my NA's I still get random NA's when I write back
> to GRASS my data.
>
> I tried to load the data, extract an NA_mask using complete.cases,
> create "fake" columns and fill-in with the _untouched_ original data and
> then write back to GRASS6. The result (or my process) is _noise_.
>
> I'll try again tonight. If I am not going to make it I could try to
> repeat this with spearfish data and see if something isn't ok with my
> MODIS bands.
>
> Cheers, Nikos
>
> I don't understand what's the deal here :-(

I am pretty sure that readRAST6() respects the current region settings in 
GRASS, however I am not sure how the 'plugin' option affects this. It could 
be that your data are being read in at different resolutions, resulting in 
different alignment of the 'bands' (columns) in the sp object. I would hope 
that this is not possible, but I cannot think of anything else.

Can you reproduce this problem with another dataset? How about a subset of the 
data?

Cheers,

Dylan



-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341


More information about the grass-stats mailing list