"rasterSampleIndices" <-
function(xyz,coords){
###
### given a list(x,y,z) and 2-column coords
###
### return indices to sample from z (2-col matrix)
###

###
### warning! presently this code assumes equal spaced x and y intervals.
###
### AND that the x and y coords are the centres of the bins.
###

#  return(cbind(1+round((coords[,1]-min(xyz$x))/(xyz$x[2]-xyz$x[1])),
#               1+round((coords[,2]-min(xyz$y))/(xyz$y[2]-xyz$y[1]))
#               )
#         )

  return(cbind(rIndex(xyz$x,coords[,1]),rIndex(xyz$y,coords[,2])))

}
