[GRASS-stats] Raster maps from GRASS to R and back to GRASS?
Nikos Alexandris
nikos.alexandris at felis.uni-freiburg.de
Mon Apr 13 19:09:27 EDT 2009
[
HiYo Dylan ;-)
]
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.
If I understand your suggestion, you mean to:
# load the bands as usual (i.e. combine a, b, c, d, e, f in one
SpatialGridDataFrame)
# create NULL-"masks" (=vectors pointing to NULLs) band-wise
# extract data of interest in a normal "data.frame" and do something
with it
# add new "columns" in the original SpatialGridDataFrame
# fill-in the results by using the per-band NULL-masks
The question that immediately pops-up is: How should I decide which
NULL-mask to use for each PC since PCA redistributes the original data?
Or is this irrelevant?
:-O
> > That is, bands d, e and f are of equal length compared to each other but
> > of different length comparing to bands a, b and c.
> > I suspect this is the root of the problem. Any suggestion?
> > Thanks, Nikos
> It could be. The way that sp objects and their 'bands' (columns in the
> attached dataframe) function makes for some tricky NULL handling.
> One thing you might consider is generating a single NULL mask that represents
> NULL values that occur in any, or all bands -- akin to an OR operation.
Hmmm... (thinking), ok, I am close... I think (!?)
> I think that na.omit(sp_object at data) may be able to return just the 'complete'
> data, along with a list of indices where NA values have been removed.
> The approach listed on the link you posted:
> x.vals <- which( !is.na(x at data$r1) & !is.na(x at data$r2) & !is.na(x at data$r3)
> & !is.na(x at data$r4))
>
> will only generate the non-NULL maks correctly when all bands have the same
> pattern of NULL values. Maybe I should add that hint.
What happens if I just replace the & with an | (=OR) operator? Isn't it
the same? (I'll try it out).
> Hope that helps,
> Dylan
Of course it helps (me). Discussions like this one are (for me) the
essence of the MLs :D
Cheers, Nikos
More information about the grass-stats
mailing list