Good day,

I have been trying to create a species richness map with ever an ever
increasing radius/distance from a cell.

I have locality data for a set of species. Converting them to a raster is
easy with:

spp.rich <- rasterize(x=sdmDB[,c("LONGITUDE","LATITUDE"),], y=ras.example,
field= as.numeric(factor(sdmDB$TAXNAME)), fun=function(x,
...){length(unique(x)) } )

However, I wish to keep the same raster resolution but also include species
located in neighbouring cells in the species richness count - i.e. how many
species are there within this and neighbouring cells. Normally one could
use the focal() function for something like this, however, the species
identities have been lost in the rasterize() process, so summing across
them is not correct.

Below is an example code for all but his last step. I would greatly
appreciate anyone's ideas on how to do this. Thanks in advance.

library(raster)
library(dismo)

r1 <- raster(nrows=50, ncols=50, xmn=0, xmx=10,ymn=0,ymx=10)
r1[] <- 0

p1 <- xyFromCell(r1, sample(1:length(r1),1000,replace=T))
s1 <- sample(1:25,1000,replace=T) # Say 25 species
spp.rich <- rasterize(x=p1, y=r1, field=s1, fun=function(x,
...){length(unique(na.omit(x))) } )

plot(spp.rich)

# But how to count species occurring in the neighbour w cells too?


-- 
Dr. Alastair J. Potts
Claude Leon Postdoctoral Fellow
Botany Department
Nelson Mandela Metropolitan University

Cell #: 082 491-7275
Office #: 041 504-4375 (Mon, Thurs, Fri)
Fax #: 086 273-2675

	[[alternative HTML version deleted]]

