SpatialPixelsDataFrame() tries to figure out how the points you feed it with are layed out on a grid structure. Small errors, possibly from rounding (you're reading from ascii) may cause it to go slightly wrong, and not give you the grid you'd like.

As you probably know the grid at which "coords.txt" is layed out, you can create it the right way and pass it to SpatialPixelsDataFrame(). Use function GridTopology() for this.

On 02/06/2013 10:45 AM, fsan...@ujaen.es wrote:
Dear R-Geo users,

I am trying to create a SP objects using SpatialPixelsDataFrame. Next I
can see the code:

proj <- '+proj=lcc +ellps=WGS84 +lat_0=0 +lat_1=30 +lat_2=60 +lon_0=-4.75'
coords <- read.table("coords.txt")
dat    <- read.table("dem.txt")
test <- SpatialPixelsDataFrame(points=coords, data=dat, proj4string=proj)

Error in if (max(object@grid.index) > .NumberOfCells(object@grid))
stop("grid.index max value too large") :
   missing value where TRUE/FALSE needed
In addition: Warning messages:
1: In points2grid(points, tolerance, round) :
   grid has empty column/rows in dimension 1
2: In points2grid(points, tolerance, round) :
   grid topology may be corrupt in dimension 1
3: In points2grid(points, tolerance, round) :
   grid has empty column/rows in dimension 2
4: In points2grid(points, tolerance, round) :
   grid topology may be corrupt in dimension 2
5: In getGridIndex(coordinates(points), grid) : NAs introduced by coercion

What's the problem?

PD: I can not attach data for this because the size exceeds the maximum
allowable.

Thanks in advance.

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


--
Edzer Pebesma
Institute for Geoinformatics (ifgi), University of Münster
Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
http://www.52north.org/geostatistics      e.pebe...@wwu.de

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to