[R-sig-Geo] SpatialPoint to SpatialGrid with unequal distributed points

Stefan Muthers smu at z107.de
Thu Sep 16 20:31:35 CEST 2010


Hello,

this is probably a beginners question, but I found no solution on the
web.

If am using data from a climate model with the cell positions given in
geographic coordinates. Unfortunatly the distance between the cells is
uneven (due to runding errors and maybe the projection) and the
"gridded" command fails to determine the correct cell size.


Consider the following example:


library(fields)
library(sp)   

link <- "http://z107.de/uni/example16092010.RData"
load(url(link))

coordinates(data) <- c("lon","lat")
gridded(data) <- TRUE  
# Warnmeldungen:
#1: In points2grid(points, tolerance, round, fuzz.tol) :  
#  grid has empty column/rows in dimension 1
#2: In points2grid(points, tolerance, round, fuzz.tol) :
#  grid has empty column/rows in dimension 2

data_sp <- as(data, "SpatialGridDataFrame")
g_plot <- as.image.SpatialGridDataFrame(data_sp["Therm.Eignung"])
image.plot(g_plot)



The resulting map contains only small stripes and much empty space.
summary(data) reveals, that the cellsize if much to small (cell should
be quadratic with a cellsize of ~ .16) and to many cells were found in
the y-direction. 

When I replace the lat and lon values with simple x and y coordinates,
everything works fine, but then it is not possible to overlay a shape
file, that displays the country borders.

Any ideas, why the cellsize-estimation is so different from the real
value and what I can do, to create a raster map with this data?


thank you and best regards,

 stefan



More information about the R-sig-Geo mailing list