[R-sig-Geo] problem in krige function

temiz temiz at deprem.gov.tr
Fri Apr 6 16:19:29 CEST 2007


Edzer J. Pebesma wrote:
> temiz wrote:
>> ...
>> I regarded some modifications in 
>> http://grass.gdf-hannover.de/wiki/GRASS_6_Tutorial#GRASS_and_R_kriging_interpolation 
>>
>>
>> I encountered a new problem :
>>  > OK_pred <- krige(z ~ 1, el3, newdata=mask_SG, model=efitted)
>> [using ordinary kriging]
>>
>> "memory.c", line 57: can't allocate memory in function m_get()
>> Error in predict.gstat(g, newdata = newdata, block = block, nsim = 
>> nsim,  :
>>         m_get
>>
>>
>>
>> Why does this problem arise ?
>>
>> I selected a great deal smaller area in R than I did in grass and 
>> carried out with spline tension without any problem.
>>
>> is the data too dense or grid size too small ?
>>
>>   
> Hard to tell without knowing the dimensions from el3 and mask_SG. 
> Kriging involves solving a system as large as the full covariance 
> matrix of the data, if you don't constrain it to looking at local 
> search neighbourhoods only. So, if el3 has 10.000 points, you're 
> trying to form a covariance matrix of 800 Mb.
>
> I'd suggest you look into setting the nmax or maxdist arguments to 
> krige() if this seems the case.
>
> And yes, if mask_SG is massively large, than that may be the cause and 
> you may want to split up the problem in a batch of smaller ones.
> -- 
> Edzer
>
>
thank you ?


here is my data profile:

 > str(mask_SG)
Formal class 'SpatialGridDataFrame' [package "sp"] with 6 slots
  ..@ data       :'data.frame': 549792 obs. of  1 variable:
  .. ..$ k: num [1:549792] 1 1 1 1 1 1 1 1 1 1 ...
  ..@ grid       :Formal class 'GridTopology' [package "sp"] with 3 slots
  .. .. ..@ cellcentre.offset: num [1:2]  449088 4584535
  .. .. ..@ cellsize         : num [1:2] 10 10
  .. .. ..@ cells.dim        : int [1:2] 747 736
  ..@ grid.index : int(0)
  ..@ coords     : num [1:2, 1:2]  449088  456548 4584535 4591886
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : NULL
  .. .. ..$ : chr [1:2] "coords.x1" "coords.x2"
  ..@ bbox       : num [1:2, 1:2]  449083 4584530  456553 4591891
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:2] "coords.x1" "coords.x2"
  .. .. ..$ : chr [1:2] "min" "max"
  ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
  .. .. ..@ projargs: chr " +proj=utm +zone=36 +ellps=intl +units=m 
+no_defs"

~~~~~~~~~~~~

 > str(el3)
Formal class 'SpatialPointsDataFrame' [package "sp"] with 5 slots
  ..@ data       :'data.frame': 24051 obs. of  4 variables:
  .. ..$ cat: num [1:24051] 1 2 3 4 5 6 7 8 9 10 ...
  .. ..$ x  : num [1:24051] 449114 449204 449262 449263 449276 ...
  .. ..$ y  : num [1:24051] 4590406 4590375 4590117 4590304 4590214 ...
  .. ..$ z  : num [1:24051] 110 110 110 110 110 110 110 110 110 110 ...
  ..@ coords.nrs : num(0)
  ..@ coords     : num [1:24051, 1:2] 449114 449204 449262 449263 449276 ...
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : NULL
  .. .. ..$ : chr [1:2] "coords.x1" "coords.x2"
  ..@ bbox       : num [1:2, 1:2]  449083 4584531  456552 4591890
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:2] "coords.x1" "coords.x2"
  .. .. ..$ : chr [1:2] "min" "max"
  ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
  .. .. ..@ projargs: chr " +proj=utm +zone=36 +ellps=intl +units=m 
+no_defs"


I tried different maxdist,nmin,and nmax values as
OK_pred <- krige(z ~ 1, el3, newdata=mask_SG, 
model=efitted,maxdist=100,nmin=2,nmax=5)

now, it gives:

"chfactor.c", line 130: singular matrix in function LDLfactor()
Error in predict.gstat(g, newdata = newdata, block = block, nsim = nsim,  :
        LDLfactor


what happens if real data and predicted data overlap ?


-- 
Ahmet Temiz


-- 
This message has been scanned for viruses and\ dangerous con...{{dropped}}




More information about the R-sig-Geo mailing list