trouble coercing SpatialPixelsDataFrame into SpatialGridDataFrame?
On Wed, 20 Oct 2010, ElenaC wrote:
I can't reproduce the problem with the meuse data either, so I've uploaded my original data: http://r-sig-geo.2731867.n2.nabble.com/file/n5655660/data_error.RData data_error.RData I get the problem when I do: library(sp) load("data_error.RData") summary(data_pixels) summary(as(data_pixels,'SpatialGridDataFrame'))
Thanks for posting the data. The problem is that your TRUE values are duplicate observations, so that TRUE is assigned to the grid cell first, because they come "before" FALSE (observations 1:241): length(slot(data_pixels, "grid.index")) length(unique(slot(data_pixels, "grid.index"))) zerodist(data_pixels) How was the data_pixels object constructed? Did you intend to have duplicate pixels? Maybe the SpatialPixels constructor should warn if points are duplicated? Hope this helps, Roger
Here is the output from sessionInfo:
sessionInfo()
R version 2.10.1 (2009-12-14) x86_64-apple-darwin9.8.0 locale: [1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] sp_0.9-65 loaded via a namespace (and not attached): [1] grid_2.10.1 lattice_0.18-3
Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no