[R-sig-Geo] Error in validityMethod(object) using SpatialGridDataFrame

Maxime Pauwels Maxime.Pauwels at univ-lille1.fr
Wed Dec 22 16:15:59 CET 2010


Dear list,

I try to create an object of class SpatialGridDataFrame-class and got 
the following error I do not understand.
Error in validityMethod(object) :
   unequal number of objects in full grid and data slot

There is the script I use. Does anyone could help me understanding where 
I am wrong?

Many thanks

max


rgrd <- GridTopology(cellcentre.offset=c(-4.5,40), cellsize=c(0.1674757, 
0.1674757), cells.dim=c(207, 90))
summary(rgrd)
#Grid topology:
#  cellcentre.offset  cellsize cells.dim
#1              -4.5 0.1674757       207
#2              40.0 0.1674757        90
rdata<-SpatialGridDataFrame(rgrd, data=read.table("rdataNssSF.txt", 
header=T), proj4string=CRS("+proj=longlat"))
#Error in validityMethod(object) :
#  unequal number of objects in full grid and data slot
#
#
#However
data=read.table("rdataNssSF.txt")
class(data)
#[1] "data.frame"
#and
coordinates(data)=~long+lat
gridded(data)=TRUE
summary(data)
#Object of class SpatialPixelsDataFrame
#Coordinates:
#           min      max
#long -4.583738 30.08374
#lat  39.915730 55.08427
#Is projected: NA
#proj4string : [NA]
#Number of points: 15267
#Grid attributes:
#     cellcentre.offset  cellsize cells.dim
#long              -4.5 0.1674757       207
#lat               40.0 0.1685393        90
#Data attributes:
#    Min.  1st Qu.   Median     Mean  3rd Qu.     Max.
#-0.75140 -0.15700  0.01150  0.03421  0.22100  0.85000



-- 
Maxime Pauwels
Researcher ID: http://www.researcherid.com/rid/A-1745-2009

Equipe Génétique&  évolution de l'adaptation aux environnements pollués par les métaux lourds
Laboratoire de Génétique et Evolution des Populations Végétales
FRE CNRS 3268
Bâtiment SN2
Université de Lille, USTL-Lille1
http://gepv.univ-lille1.fr
Tel  : +33 3 20 33 62 38
Fax  : +33 3 20 43 69 79



More information about the R-sig-Geo mailing list