[R-sig-Geo] for loop for raster class
Vikram Ranga
babuawara at gmail.com
Thu Jan 12 13:38:16 CET 2012
Hi Edzer,
It worked!!!!!
Thanks a million
Vikram.
On 1/12/2012 12:56 PM, Edzer Pebesma wrote:
> The error message suggests ls.im is a list; your script would be easier
> to understand (for me) if you used
>
> ls.im = list(x1=janb3,...,x10=decb4)
>
> If ls.im is a list, you need to pass ls.im[[i]] to crop, which is a list
> element (a raster), whereas ls.im[i] is a list (with one element).
>
> On 01/12/2012 12:50 PM, Vikram Ranga wrote:
>> Hi,
>> I am trying to crop images using raster library it works fine but when i
>> put that on loop it does not work
>> my syntax is
>> febb3<-raster("C:/landsat/New
>> Landsat/February/L5146041_04120110201_B30.tif")
>> febb4<-raster("C:/landsat/New
>> Landsat/February/L5146041_04120110201_B40.tif")
>> .
>> .
>> .
>> .
>> so on
>> msk<-raster("C:/landsat/mask.tif")
>> ls.im<-c(x1=janb3,x2=janb4,x3=febb3,x4=febb4,x5=octb3,x6=octb4,x7=novb3,x8=novb4,x9=decb3,x10=decb4)
>>
>> ls.em<-c(1:10)
>> #for loop
>> for (i in 1:1){ls.em<-crop(ls.im[i],msk)}
>> error
>> Error in function (classes, fdef, mtable) :
>> unable to find an inherited method for function "crop", for signature
>> "list"
>> I think there is a problem with the c or list function for concatenating
>> all the images. I tried few things but no luck.
>> Any help would be highly appreciated.
>>
>> Regards,
>> Vikram.
>>
>> _______________________________________________
>> 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