[R-sig-Geo] Error using SpatialPixelsDataFrame function

Edzer Pebesma edzer.pebesma at uni-muenster.de
Wed Feb 6 10:59:49 CET 2013


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, fsantos at 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 at grid.index) > .NumberOfCells(object at 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 at 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.pebesma at wwu.de



More information about the R-sig-Geo mailing list