Dear Roger,

Sorry for my delay.

I still can't do that. Please, see below the steps and the error message.
I shapefile have only one polygon, and only one collumn (CoverClass).

> reser<-readOGR(dsn=".", layer="ARN_026_214pt5m")
OGR data source with driver: ESRI Shapefile
Source: ".", layer: "ARN_026_214pt5m"
with  1  rows and  3  columns
Feature type: wkbPolygon with 2 dimensions
> reser.df<-re...@data
> reser.df$ClassCover<-1
> reser.df<-subset(reser.df, select=c(ClassCover))
> re...@data<-reser.df <re...@data%3c-reser.df>
> re...@data
  ClassCover
0          1
> reser.SG <- Sobj_SpatialGrid(reser)$SG
>
> plot(reser.SG)
> plot(reser, add=T, col="red")
> str(reser.SG)
Formal class 'SpatialGrid' [package "sp"] with 5 slots
  ..@ grid       :Formal class 'GridTopology' [package "sp"] with 3 slots
  .. .. ..@ cellcentre.offset: Named num [1:2] 371506 8764564
  .. .. .. ..- attr(*, "names")= chr [1:2] "x" "y"
  .. .. ..@ cellsize         : Named num [1:2] 941 941
  .. .. .. ..- attr(*, "names")= chr [1:2] "max" "max"
  .. .. ..@ cells.dim        : int [1:2] 100 75
  ..@ grid.index : int(0)
  ..@ coords     : num [1:2, 1:2] 371506 464669 8764564 8834201
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : NULL
  .. .. ..$ : chr [1:2] "x" "y"
  ..@ bbox       : num [1:2, 1:2] 371035 8764093 465139 8834672
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:2] "x" "y"
  .. .. ..$ : chr [1:2] "min" "max"
  ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
  .. .. ..@ projargs: chr NA
> o <- overlay(reser, reser.SG)
> o
     ClassCover
NA           NA
NA.1         NA
> reser.SGDF <- SpatialGridDataFrame(slot(reser.SG, "grid"),
+   proj4string=CRS(proj4string(reser.SG)), data=o)
Error in validityMethod(object) :
  unequal number of objects in full grid and data slot
>


> sessionInfo()
R version 2.9.0 alpha (2009-03-26 r48224)
i386-pc-mingw32
locale:
LC_COLLATE=English_Canada.1252;LC_CTYPE=English_Canada.1252;LC_MONETARY=English_Canada.1252;LC_NUMERIC=C;LC_TIME=English_Canada.1252
attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
other attached packages:
[1] raster_0.8.9-6  maptools_0.7-20 foreign_0.8-34  rgdal_0.6-7
[5] sp_0.9-32
loaded via a namespace (and not attached):
[1] grid_2.9.0      lattice_0.17-20

Best wishes,

milton

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to