[Rspatial-devel] sp change in handling gridded data
Edzer Pebesma
edzer.pebesma at uni-muenster.de
Tue May 24 12:58:35 CEST 2011
selection [ on SpatialPixels has now as default drop=FALSE (was: drop=TRUE)
On 05/24/2011 12:04 PM, Edzer Pebesma wrote:
> [r-spatial-devel included, but please continue any discussion about sp
> on the r-forge list]
>
> I'm proposing a change in the way sp handles gridded data. Right now, a
> data set with coordinates
>
> x y
> 1 1
> 1 2
> 1 3
>
> cannot be coerced to SpatialPixels (gridded(x) = TRUE) because from the
> x coordinate we cannot figure out the grid cell size.
>
> My proposal is to change this, and when another coordinate (y) can give
> the grid cell size, to take that one as grid cell size. This would then
> generate the following warning:
>
> Warning message:
> In points2grid(points, tolerance, round) :
> cell size from constant coordinate 2 possibly taken from other coordinate
>
> library(sp)
> data(meuse.grid)
> gridded(meuse.grid) = ~x+y
> meuse.grid[2:3,]
>
> used to generated an error, but would now pass with this warning.
>
> As the major nuissance with this is when selecting few or single pixels,
> I modified the behaviour of [ on SpatialPixels[DataFrame]s. The default
> is drop=FALSE, which will keep the original @grid GridTopology, so that
>
> meuse.grid[1,]
>
> will result in a single-pixel grid, with grid topology from meuse.grid,
> whereas
>
> meuse.grid[1,drop=TRUE]
>
> will result in an error (cannnot derive grid from single point), and
>
> meuse.grid[2:3, drop=TRUE]
>
> will result in the warning message above. SpatialPixels() and
> SpatialPixelsDataFrame() now have a grid=NULL argument, that, when
> specified, will take these grid topologies instead of those derived from
> the points.
>
> I committed this to r-forge, and hope you like it. Reactions more than
> welcome. An appropriate message to r-sig-geo at (or before?) next
> release of sp is useful, i suppose.
--
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 Rspatial-devel
mailing list