[R-sig-Geo] Mean of SpatialGridDataFrames or SpatialPixelsDataFrames
Baalam Kan
spamgoodbye at me.com
Fri Dec 21 18:47:05 CET 2012
Hello List:
[Sorry for my last email in HTML format!]
I'm using the adehabitatHR package to obtain several "Utilization Distribution" maps for some individuals of a same species. Now, I want combine these in a single map using a mean value. The overlay function don't work for me in this issue.
Shortly, I want average one SpatialGridDataFrame over other SpatialGridDataFrame.
I hope someone can help.
Any ideas as to what might be going on?
Thanks,
Andres
======= CODE =========
class(UD_obj)
[1] "estUDm"
UD_spixdf <- estUDm2spixdf(UD_obj) # Several SpatialPixelsDataFrames
class(UD_spixdf)
[1] "SpatialPixelsDataFrame"
attr(,"package")
[1] "sp"
UD_spixdf_1 <- UD_spixdf[1] # The first SpatialPixelsDataFrame to combine
class(UD_spixdf_1)
[1] "SpatialPixelsDataFrame"
attr(,"package")
[1] "sp"
UD_spixdf_2 <- UD_spixdf[2] # The second SpatialPixelsDataFrame to combine
class(UD_spixdf_2)
[1] "SpatialPixelsDataFrame"
attr(,"package")
[1] "sp"
UD_mean <- overlay(as(UD_spixdf_1, "SpatialGridDataFrame"), UD_spixdf_2, fn=mean)
gridded(UD_mean) = TRUE
UD_mean_grid <- as.image.SpatialGridDataFrame(UD_mean)
image(UD_mean_grid)
More information about the R-sig-Geo
mailing list