Skip to content

Problems with image2Grid

2 messages · fernando espindola, Roger Bivand

#
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.

Thank for all

fernando
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20090923/d2499241/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example.RData
Type: application/octet-stream
Size: 51664 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20090923/d2499241/attachment.obj>
#
On Wed, 23 Sep 2009, fernando espindola wrote:

            
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