[R] Problem with filled.contour/image

Petr Pikal petr.pikal at precheza.cz
Thu May 6 12:18:18 CEST 2004


Hi

Hi

x,y are supposed to be vectors with lengths n and m and the matrix is supposed to 
have dimensions n,m

> ?image
> data(volcano)
>      x <- 10*(1:nrow(volcano))
>      y <- 10*(1:ncol(volcano))
>      image(x, y, volcano, col = terrain.colors(100), axes = FALSE)
> length(x)
[1] 87
> length(y)
[1] 61
> dim(volcano)
[1] 87 61

did you get similar figures for your data?

Cheers
Petr



On 6 May 2004 at 10:41, Laura Quinn wrote:

> Quick question - I am having problems creating an orographic image
> (similar to volcano example). I have created a map matrix with 3
> columns and over 2million rows.
> 
> I have created the matrix as follows:
> map<-read.table("map.dat",header=TRUE)
> long.grid<-sort(unique(map$long)
> lat.grid<-sort(unique(map$lat)
> map.matrix<-matrix(map$height,nrow=length(lat.grid),byrow=TRUE)
> 
> The problem is when I type the filled.contour
> command I get the following error message:
> 
> filled.contour(long.grid,lat.grid,t(map.matrix),color=terrain.colors)
> 
> Error in filledcontour(as.double(x), as.double(y), z,
> as.double(levels), :
>         dimension mismatch
> 
> and when I try using the image function:
> 
> image(long.grid,lat.grid,t(map.matrix),col=terrain.colors(50),axes=TRU
> E)
> 
> I get the following error:
> 
> Error in image.default(long.grid, lat.grid, t(map.matrix), col =
> terrain.colors(50),  :
>         dimensions of z are not length(x)(+1) times length(y)(+1)
> 
> Each long and lat point are unique and have a corresponding height
> component so these messages don't make any sense to me - can anyone
> please advise?
> 
> Thanks
> 
> Laura
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html

Petr Pikal
petr.pikal at precheza.cz




More information about the R-help mailing list