[R-sig-Geo] Problems with image2Grid
Roger Bivand
Roger.Bivand at nhh.no
Thu Sep 24 08:19:11 CEST 2009
On Wed, 23 Sep 2009, fernando espindola wrote:
> Hi R-sig-Geo user,
>
> I am try to convert matrix to SpatialGridDataFrame using the image2Grid
> function, but the range of longitude change with apply this function. I
> include the object with the x-longitude, y-latitude and z-matrix.
Since no-one can see over your shoulder, including the commands you use,
and the (textual) output you receive, in your posting might have been
useful. Reconstructing from the attached data file (which you have sent to
over 1200 people through the list), it seems that you are confusing the
range of the raster cell centre points, and the bounding box of the
object, which must add half a cell width/height at the edges (otherwise it
would bound such that half of the outer cell rows and columns would be
clipped):
library(sp)
load("example.RData")
t1 <- image2Grid(met)
proj4string(t1) <- CRS("+proj=longlat")
image(t1, axes=TRUE)
range(met$x)
# [1] -77.25511 -64.67870
range(met$y)
# [1] -58.32734 -41.10675
bbox(t1)
# min max
# coords.x1 -77.35186 -64.58196
# coords.x2 -58.37497 -44.08401
bbox(t1)[1, 1] + 0.5 * gridparameters(t1)$cellsize[1]
# [1] -77.25511
bbox(t1)[1, 2] - 0.5 * gridparameters(t1)$cellsize[1]
# [1] -64.6787
summary(t1)
# reports the bounding box of the object.
OK?
Roger
>
> Thank for all
>
> fernando
>
--
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
More information about the R-sig-Geo
mailing list