[GRASS-stats] Raster maps from GRASS to R and back to GRASS?
Roger Bivand
Roger.Bivand at nhh.no
Tue Apr 14 14:08:40 EDT 2009
On Tue, 14 Apr 2009, Dylan Beaudette wrote:
> 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.
This looks possible, but if the data are all read in a single call to
readRAST6() is not, because plugin is set to FALSE even if present when
more than one raster is being transferred (and when the plugin raster
doesn't seem to be in the current region settings).
Without a reproducible example, we are not going to get anywhere, I'm
afraid. We must have a tarball of the location, and the exact R code being
used.
Roger
>
> Can you reproduce this problem with another dataset? How about a subset of the
> data?
>
> Cheers,
>
> Dylan
>
>
>
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the grass-stats
mailing list