transectGrid <- function(p1,p2,grido){
  x1=p1$x
  y1=p1$y
  x2=p2$x
  y2=p2$y
  gs=min(diff(grido$x),diff(grido$y))/4
  dt=sqrt((x2-x1)^2+(y2-y1)^2)
  np=dt/gs
  xc=seq(x1,x2,len=np)
  yc=seq(y1,y2,len=np)
  rsi=rasterSampleIndices(grido,cbind(xc,yc))
  return(cbind(xc,yc,grido$z[rsi]))
}
