[R-sig-Geo] Storing List data-types as Raster values

Robert J. Hijmans r.hijmans at gmail.com
Sat Sep 28 15:51:14 CEST 2013


Lionel,

You can do:

library(raster)
b <- brick(nl=2, ncol=5, nrow=5)
b[1] <- cbind(14,20)
head(as.matrix(b))

cell numbers are implicit so you do not need to create a layer for these.

Robert


On Fri, Sep 27, 2013 at 7:51 AM, shahab <shahab.mokari at gmail.com> wrote:
> Thanks Lionel, Lets see what I can do. A amjor issue is that  I need toe
> keep pair of values (id, direction) and maintaining this pair relation
> while spreading them in different layers becomes problematic.
>
> Again thanks,
>
>
> On Fri, Sep 27, 2013 at 2:57 PM, Lionel <s6lihert at uni-bonn.de> wrote:
>
>> Dear Shahab,
>>
>> Indeed each raster cell should contain an unique value, I guess this is
>> part of the definition of what a raster is. What you could do is put your
>> different variable (id, direction) in different layer of a raster stack.
>> See ?stack for example.
>>
>> Yours,
>> Lionel
>>
>>
>> On 09/27/2013 02:33 PM, shahab wrote:
>>
>>> Hi,
>>>
>>> I am quite new to Raster library and a bit confused.
>>> Basically I would like to raster an area, and then place information
>>> (Identifuer, Direction) in each cell ,as follows:
>>>
>>>  myraster<-raster()
>>>>   myraster[1:3]<-list(id=c(1),**direction=c(14,20))
>>>>
>>> Error in min(vals) : invalid 'type' (list) of argument
>>> In addition: Warning message:
>>> In .replace(x, i = i, value = value, recycle = 1) :
>>>    number of items to replace is not a multiple of replacement length
>>>
>>>
>>> It seems to me that I can not put an object of type List,or vector,...in
>>> the cells??
>>>
>>> If this is the case, what would be the alternative solutions?
>>>
>>> /Shahab
>>>
>>>         [[alternative HTML version deleted]]
>>>
>>> ______________________________**_________________
>>> R-sig-Geo mailing list
>>> R-sig-Geo at r-project.org
>>> https://stat.ethz.ch/mailman/**listinfo/r-sig-geo<https://stat.ethz.ch/mailman/listinfo/r-sig-geo>
>>>
>>
>> ______________________________**_________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/**listinfo/r-sig-geo<https://stat.ethz.ch/mailman/listinfo/r-sig-geo>
>>
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list