[R-sig-Geo] Problem with locations in image() in GeoR

Roger Bivand Roger.Bivand at nhh.no
Mon Jan 31 09:34:56 CET 2005


On Mon, 31 Jan 2005, Rafal Buczkowski wrote:

> Hello
> 
> I am doing kriging with:
> 
> krigres=krige.conv(geozadrz , geozadrz$coords, geozadrz$data, locs , 
> borders=NULL, krigcont )
> 
> and I would like to use as locations frame of coordinates of points which 
> cover the area I am interested in. Area is not a square. When I want to plot 
> kriging results with:
> 
> image(krigres)
> 
> the following error appears
> 
> Error in image.default(x = c(3617675, 3617875, 3617975, 3618075, 3618175,  :
>         dimensions of z are not length(x)(+1) times length(y)(+1)
> In addition: Warning message:
> data length [2703] is not a sub-multiple or multiple of the number of rows 
> [29] in matrix
> 
> and after I reduced the number of rows of my locations to number which is 
> multiple of 29 the following message appeared:
> 
> Error in image.default(x = c(3617675, 3617875, 3617975, 3618075, 3618175,  :
>         dimensions of z are not length(x)(+1) times length(y)(+1)
> In addition: Warning message:
> data length [2703] is not a sub-multiple or multiple of the number of rows 
> [29] in matrix
> 
> My list of coordinates is not a square. Does image() accept only square 
> areas? I am using coordinates of points from my area to avoid doing kriging 
> for points which out outside area of my research.

Yes, image only accepts rectangular areas, typically taking an xseq, yseq, 
and z list as input (xseq the grid centres eastings, yseq grid centre 
northings, and z the matrix with NA where there is no data). If you want 
to predict and then use image(), you need to insert the predictions into 
the full matrix, leaving NAs where there is no data.

An alternative is to use levelplot() in the lattice package, which takes a 
formula z ~ x + y, and fills in the NAs itself. Both approaches have their 
advantages and disadvantages. Some examples of using levelplot() are in 
some of my lecture notes (Week 41 in 
http://spatial.nhh.no/geo304/modules-h04.html).

You will find similar code and examples in the gstat package. Edzer
Pebesma's function xyz2img() in that package may be the the simplest way 
to go, it needs a data frame with x, y, and z columns, and outputs the 
kind of list image() likes.

Hope this helps,

Roger

> 
> Thanks in advance for your help
> 
> Rafal Buczkowski
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no




More information about the R-sig-Geo mailing list