[R-sig-Geo] problem in krige function
temiz
temiz at deprem.gov.tr
Fri Apr 6 19:29:37 CEST 2007
Edzer J. Pebesma wrote:
> Most probably you have duplicate points in your observations.
>
> You may try to use zerodist() to find them, or remove.duplicates() to
> remove them but this may currently run out of memory as the current
> implementation forms the full distance matrix. In that case you'd have
> to go through it in parts.
> --
> Edzer
>
> temiz wrote:
>> 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 ?
>>
>>
>
>
I tried :
> zerodist(el3$x, el3$y,el3$z, zero = 0.0)
Error in zerodist(el3$x, el3$y, el3$z, zero = 0) :
unused argument(s) (c(4590405.661827, 4590374.745888,
4590116.746993, 4590303.944226, 4590213.551664, 4590021.100459,
4589924.277879, 4589828.612158, 4589739.33, 4589526.363336,
4589123.641052, 4589214.602309, 4589127.09066, 4589307.025734,
4589488.585501, 4589394.940462, 4589185.586814, 4589256.657301,
4589349.740632, 4589739.33, 4589446.095212, 4589642.691654,
4589544.436132, 4590464.7, 4590464.7, 4590432.214366, 4590356.815318,
4589884.257655, 4589980.37416, 4590076.599159, 4590271.149476,
4589788.818878, 4589403.306827,
> remove.duplicates(el3, zero = 0.0, remove.second = TRUE)
Error: cannot allocate vector of size 2259572 Kb
Is there another way rather than choosing smaller region ?
regards
--
Ahmet Temiz
--
This message has been scanned for viruses and\ dangerous con...{{dropped}}
More information about the R-sig-Geo
mailing list