[R-sig-Geo] changes to SpatialGrid in sp_0.9-94

Edzer Pebesma edzer.pebesma at uni-muenster.de
Wed Feb 1 11:20:51 CET 2012


Dear r-sig-geo-ers,

sp 0.9-94 has been released and will propagate through the CRAN networks.

The class hierarchy in sp has been slightly modified in the upcoming sp
version. In particular, SpatialGrid no longer "is" SpatialPixels, and
the same is true for objects of class SpatialGridDataFrame.

The binary representation also changed, as obsolete slots (coords,
grid.index) could be removed. It seems that saved R data bases will
still work with the new sp versions, as only slots disappeared. The
reverse is not true (saved 0.9-94 objects will create errors when run
with sp 0.9-93).

The main reason for this change is a strong performance improvement when
large images are read (e.g. by rgdal::readGDAL) into
SpatialGridDataFrame objects.

This change may affect the working of scripts that depend on the old sp
behaviour. If so, an explicit coercion of a SpatialGridDataFrame object
x needs to be added, as in:

x = as(x, "SpatialPixelsDataFrame")

or, equivalently:

fullgrid(x) = FALSE

before you pass on the object to the routine that assumes x to be a
SpatialPixels. And there may be other issues that I missed, of course.

sp version up to 0.9-93 had:

> library(sp)
> data(meuse.grid)
> gridded(meuse.grid)=~x+y
> fullgrid(meuse.grid)=TRUE
> is(meuse.grid)
[1] "SpatialGridDataFrame" "SpatialGrid"        "SpatialPixels"
[4] "SpatialPoints"        "Spatial"
> slotNames(meuse.grid)
[1] "data"        "coords"      "grid"     "grid.index"  "bbox"
[6] "proj4string"

from 0.9-94 on:

> library(sp)
> data(meuse.grid)
> gridded(meuse.grid)=~x+y
> fullgrid(meuse.grid)=TRUE
> is(meuse.grid)
[1] "SpatialGridDataFrame" "SpatialGrid"         "Spatial"
> slotNames(meuse.grid)
[1] "data"        "grid"        "bbox"        "proj4string"

In case of questions, please ask, on- or off-list.
-- 
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