[R-sig-Geo] get() in raster ?

Edzer Pebesma edzer.pebesma at uni-muenster.de
Sat Nov 20 12:23:57 CET 2010


Agus, maybe what you're looking for is

v = list("r1","r2","r3")
do.call(brick, v)


On 11/20/2010 11:51 AM, Agustin Lobo wrote:
> ok, the problem is that, as noted by Carson,
> I must use get("v") and not get(v).
> 
> But still have problems to use get() within stack() or brick():
>> r1 = raster(SM[,,1])
>> r2 = raster(SM[,,2])
>> r3 = raster(SM[,,3])
>> v = c("r1","r2","r3")
>> get("v")
> [1] "r1" "r2" "r3"
>> bSM = brick(get(v))
> Error in .rasterObjectFromFile(x, objecttype = "RasterBrick", ...) :
>   file: r1r2r3 does not exist
> Calls: brick -> brick -> .local -> .rasterObjectFromFile
> 
> ( I'm trying to use get() because have to
> create a brick with 360 files that have been read as raster objects within
> a loop using assign() )
> 
> Agus
> 
> 
> 2010/11/19 Robert J. Hijmans <r.hijmans at gmail.com>:
>> This suggest that you have an object "r1" that is a Raster* object.
>> Perhaps because of a saved session?
>> Have you looked at
>> ls()
>> Robert
>>
>> On Fri, Nov 19, 2010 at 1:24 PM, Agustin Lobo <alobolistas at gmail.com> wrote:
>>> Hi again!
>>>
>>> I'm having problems because cannot use get()  from base once package
>>> raster has been installed:
>>>
>>>> v = c("r1","r2","r3")
>>>> v
>>> [1] "r1" "r2" "r3"
>>>> get(v)
>>> Loading required package: raster
>>> Loading required package: sp
>>> raster version 1.6-22 (17-November-2010)
>>> class       : RasterLayer
>>> nrow        : 18
>>> ncol        : 36
>>> ncell       : 648
>>> projection  : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
>>> xmin        : -180
>>> xmax        : 180
>>> ymin        : -90
>>> ymax        : 90
>>> xres        : 10
>>> yres        : 10
>>>
>>> Even not having loaded raster, it gets automatically loaded once I
>>> call get(). Is this a bug?
>>> In general, is there a way to force that, in case of conflict, you run
>>> a particular function from a given package?
>>>
>>> Thanks!
>>>
>>> Agus
>>>
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo

-- 
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebesma at wwu.de



More information about the R-sig-Geo mailing list