Skip to content

Problems with SpatialPixelsDataFrame objects

2 messages · Pedro Perez, Zia Ahmed

#
Hi everybody,

The following two scripts will generate a "SpatialPixelDataFrame" object:

# FIRST
library(rgdal)
elev.grid <- readGDAL("whatever.asc")
elev.grid <- as(elev.grid, "SpatialPixelsDataFrame")

# SECOND
library(raster)
library(SDMTools)
library(adehabitat)
elev.grid <- raster("whatever.asc")
elev.grid.asc <- asc.from.raster(elev.grid)
elev.grid.SPDF <- asc2spixdf(elev.grid.asc)


HOWEVER, the first one excedes the capability of my computing
resources when applying it to big (15000 x 16000) grids, and the
second one generates an object which I can't use for some further
analyses. For example, when I use it for krige purposes

x <- krige(V3~var, points, elev.grid)

I get the following:

Error in model.frame.default(terms(formula), as(data, "data.frame"),
na.action = na.fail) :
  invalid type (closure) for variable 'var'

I will be really thankful if somebody is kind enough to tell me how to
fix it, whether providing me a trick to handle the memory/capability
issue of the first case, or fixing the error generated by the second
case.

THANKS A LOT IN ADVANCE!!!

Paolo
#
Dear List,
I am trying to calculate

*GLCM textures of all bands of a raster stack using GLCM package.  Using
following code it runs perfectly. The code created  four stacks for each
bands,  each stack contains for 8 raster objects,   but I am facing
difficulty  to get results for further analysis.  I appreciate if some one
help me out how to extract  four raster stacks from the results (glcm.all).*

*Thanks*

*Zia*
class       : RasterStack
dimensions  : 167, 213, 35571, 8  (nrow, ncol, ncell, nlayers)
resolution  : 30, 30  (x, y)
extent      : 826245, 832635, 1107825, 1112835  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=16 +ellps=WGS84 +units=m +no_defs
names       :   glcm_mean, glcm_variance, glcm_homogeneity,
glcm_contrast, glcm_dissimilarity, glcm_entropy, glcm_second_moment,
glcm_correlation
min values  :  0.05902778,    3.10906455,       0.02218517,
0.00000000,         0.00000000,   0.00000000,         0.11111111,
       -Inf
max values  :   0.6927083,   497.8806062,        1.0000000,
118.5555556,          9.6666667,    2.1972246,          1.0000000,
         Inf


[[2]]
class       : RasterStack
dimensions  : 167, 213, 35571, 8  (nrow, ncol, ncell, nlayers)
resolution  : 30, 30  (x, y)
extent      : 826245, 832635, 1107825, 1112835  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=16 +ellps=WGS84 +units=m +no_defs
names       :   glcm_mean, glcm_variance, glcm_homogeneity,
glcm_contrast, glcm_dissimilarity, glcm_entropy, glcm_second_moment,
glcm_correlation
min values  :  0.04687500,    1.84165521,       0.03395896,
0.00000000,         0.00000000,   0.00000000,         0.11111111,
       -Inf
max values  :   0.7361111,   556.6514305,        1.0000000,
94.7777778,          8.7777778,    2.1972246,          1.0000000,
        Inf


[[3]]
class       : RasterStack
dimensions  : 167, 213, 35571, 8  (nrow, ncol, ncell, nlayers)
resolution  : 30, 30  (x, y)
extent      : 826245, 832635, 1107825, 1112835  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=16 +ellps=WGS84 +units=m +no_defs
names       :   glcm_mean, glcm_variance, glcm_homogeneity,
glcm_contrast, glcm_dissimilarity, glcm_entropy, glcm_second_moment,
glcm_correlation
min values  :  0.03993056,    0.91840278,       0.02775318,
0.00000000,         0.00000000,   0.00000000,         0.11111111,
       -Inf
max values  :   0.7291667,   572.3779206,        1.0000000,
147.5555556,         10.8888889,    2.1972246,          1.0000000,
         Inf


[[4]]
class       : RasterStack
dimensions  : 167, 213, 35571, 8  (nrow, ncol, ncell, nlayers)
resolution  : 30, 30  (x, y)
extent      : 826245, 832635, 1107825, 1112835  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=utm +zone=16 +ellps=WGS84 +units=m +no_defs
names       :   glcm_mean, glcm_variance, glcm_homogeneity,
glcm_contrast, glcm_dissimilarity, glcm_entropy, glcm_second_moment,
glcm_correlation
min values  :  0.07812500,    3.79071422,       0.02196611,
0.00000000,         0.00000000,   0.00000000,         0.11111111,
       -Inf
max values  :   0.8975694,   803.7921278,        1.0000000,
160.1111111,         10.6666667,    2.1972246,          1.0000000,
         Inf

        
On Sun, Nov 20, 2016 at 4:50 AM, Pedro Perez <perep1972 at gmail.com> wrote: