Dear List, I have a list of xy coordinates
> origin.point [[1]] x y 196 35.65648 4.268407 267 26.97161 -0.921370 [[2]] x y 2396 25.82682 -34.30095 2485 24.36276 -31.83600 ... and I'm tryig to extract raster cell values within the radius like so: cell.num <- unlist(xyValues(object = rst, xy = origin.point, buffer = 50)) For most coordinates, I get a list of vectors as expected, however, some fail and produce only (one) NA. The raster serving as object is always the same. For instance, in the list mentioned above, only coordinate 2 ( xy[[1]][2,]) in list 1 is causing such problems. I have tried rounding the coordinates to no avail. Unfortunately I'm unable to reproduce the same behavior outside my function. If I do it manually like so cell.num1 <- unlist(xyValues(object = rst, xy = matrix(c(35.656483, 4.268407), nrow = 1, ncol = 2), buffer = 50)) #first coordinate cell.num2 <- unlist(xyValues(object = rst, xy = matrix(c(26.97161, -0.92137), nrow = 1, ncol = 2), buffer = 50)) #second coordinate things go through without a problem. This leads me to believe there is something in or around my custom function. What is confusing me is the unpredictable behavior which makes it harder for me to pinpoint the source where everything breaks. I tried following the xyValues() but debugging S4 methods is not something I'm versed at (yet?!). I have tried extracting xyValues() with selectMethod(xyValues, c('RasterLayer', 'matrix')) but the function calls even more internal functions and here is where I get stuck. I guess my questions are: what could be causing xyValues() to produce NA for particular coordinates (but working fine with others) and - how to debug xyValues() and it's internals like .xyvBuf, .readCells...? I would really like to get to the bottom of this and move on. Cheers, Roman -- In God we trust, all others bring data. [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@stat.math.ethz.ch https://stat.ethz.ch/mailman/listinfo/r-sig-geo