Hi guys,

This is my first attemp using focal() in raster package.

Looking at the raster dimension after running focal(), it seems that
everything is OK until I plot the raster and found  out that the first and
last column/row has been change to NA.

Any help guys?

Thanks in advance.

r <- raster(ncols=5, nrows=5, xmn=0)
r[] <- runif(ncell(r))
r
> r
class       : RasterLayer
dimensions  : 10, 10, 100  (nrow, ncol, ncell)
resolution  : 18, 18  (x, y)
extent      : 0, 180, -90, 90  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names       : layer
values      : 0.01734865, 0.9977548  (min, max)

# 3x3 mean filter
r3 <- focal(r, w=matrix(1/9,nrow=3,ncol=3))
r3
> r3
class       : RasterLayer
dimensions  : 10, 10, 100  (nrow, ncol, ncell)
resolution  : 18, 18  (x, y)
extent      : 0, 180, -90, 90  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names       : layer
values      : 0.346758, 0.6850644  (min, max)

#plot 2 rasters
par(mfrow=c(1,2))
plot(r)
plot(r3)

	[[alternative HTML version deleted]]

