[R-sig-Geo] DataGrid

Anastasia Johannes stacy.johannes at gmail.com
Sun Oct 15 11:39:06 CEST 2017


I am trying to create DataGrid but I am failing to do so

Below find my code and see how my grid dataset just end up with no data.

> library(sp)

> library(gstat)

> coordinates(cor)=~x+y

> str(cor)

Formal class 'SpatialPointsDataFrame' [package "sp"] with 5 slots

  ..@ data       :'data.frame': 550 obs. of  28 variables:

  .. ..$ F         : num [1:550] 22.2 65 44.4 30 88.2 ...

  .. ..$ Poor        : num [1:550] 0 85 0 65 35.3 ...

  .. ..$ Middle      : num [1:550] 0 15 0 30 58.8 ...

  .. ..$ NoEdu       : num [1:550] 0 35 0 5 17.6 ...

  .. ..$ Prim        : num [1:550] 0 25 5.56 65 47.06 ..



> gridded(cor)<-TRUE

> str(cor)

Formal class 'SpatialPixelsDataFrame' [package "sp"] with 7 slots

  ..@ data       :'data.frame': 550 obs. of  28 variables:

  .. ..$ F         : num [1:550] 22.2 65 44.4 30 88.2 ...

  .. ..$ Poor        : num [1:550] 0 85 0 65 35.3 ...

  .. ..$ Middle      : num [1:550] 0 15 0 30 58.8 ...

  .. ..$ NoEdu       : num [1:550] 0 35 0 5 17.6 ...

  .. ..$ Prim        : num [1:550] 0 25 5.56 65 47.06 ...

  .. ..$ Sec         : num [1:550] 88.9 40 22.2 25 35.3 ...



*But when I transform to spatialGrid, the data disappear and this cause NA
in the calculation of var1.pred and var.var*

> fullgrid(cor)<-TRUE

> str(cor)

Formal class 'SpatialGridDataFrame' [package "sp"] with 4 slots

  ..@ data       :'data.frame': 1372406 obs. of  28 variables:

  .. ..$ HH         : num [1:1372406] NA NA NA NA NA NA NA NA NA NA ...

  .. ..$ Poor        : num [1:1372406] NA NA NA NA NA NA NA NA NA NA ...

  .. ..$ Middle      : num [1:1372406] NA NA NA NA NA NA NA NA NA NA ...

  .. ..$ NoEdu       : num [1:1372406] NA NA NA NA NA NA NA NA NA NA ...

  .. ..$ Prim        : num [1:1372406] NA NA NA NA NA NA NA NA NA NA ...

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list