Finally I figured it out

# my original matrix
x<-seq(29,36,2.8)#lon
y<-c(-4,-3,-1.5,0,1.5,3,4)#lat
z<-matrix(1:21,3,7)
rownames(z)<-x;colnames(z)<-y
print(z)

#I found the im function in spatstat
library(spatstat)
# Convert z matrix to pixel-image
z.im<-im(z,xcol=y,yrow=x)# xcol=ykords(cols), yrow=xkords(rows)
    #Convert created pixel image to mtrix
    z.im.mat<-as.matrix(z.im);rownames(z.im.mat)<-x;colnames(z.im.mat)<-y
    print(z.im.mat)

# New desired coordinates for resampled matrix
    xd<-seq(29,36,1)# new lon
    yd<-seq(-4,4,1) # new lat

#Resample pixellated z.im  to zd.im using as.im and xd,yd
zd.im<-as.im(z.im,xy=list(x=yd,y=xd))# the pixel image is rotated
    #Convert created pixel image to mtrix
    zd<-as.matrix(zd.im);rownames(zd)<-xd;colnames(zd)<-yd
    print(zd)

#Some diagnostic plots
par(mfrow=c(1,2))
image(x,y,z,asp=1,main="Original Matrix")
image(xd,yd,zd,col=heat.colors(20),asp=1,zlim=c(min(z.im),max(z.im)),main="Final
Resampled Matrix")



-- 
<a href="http://inside-r.org/download" title="Download R"><img src="
http://inside-r.org/sites/all/themes/rweb/assets/badges/download-r-badge-125-blue.png"
border="0" /></a>

	[[alternative HTML version deleted]]

