Skip to content
Prev 5924 / 29559 Next

convert point data to count data

Karla Falk writes:
You can use the command 'pixellate' in spatstat.

library(spatstat)

data(redwood)

Z <- pixellate(redwood, eps=0.1, padzero=TRUE)

df <- data.frame(x=rasterx.im(Z), y=rastery.im(Z), count=as.vector(as.matrix(Z)))



Then 'df' is the output table you wanted. To display it,



plot(Z)

with(df, text(x,y,count))



The size of the grid cells can be controlled using 'eps' (for squares of side length 'eps')

or 'dimyx' (specifying the number of rows and columns of cells).



Adrian Baddeley