[R-sig-Geo] going from R to ESRI grids

Timothy H. Keitt tkeitt at mail.utexas.edu
Thu Jan 6 18:09:44 CET 2005


Are you using rgdal? It reads/writes data arrays transposed. It was a
design decision to avoid the overhead of transposing very large grids (R
is column major and GDAL is row major). We could add a switch I suppose.

THK

On Thu, 2005-01-06 at 09:37, Darla Munroe wrote:
> Just wondering if others have worked with this, and if I am missing
> something totally obvious to make this simpler, apologies for my ignorance -
> 
> 
>  
> 
> OK - it is my understanding that when you reshape a vector (nx1) into a
> matrix in R, it reads the matrix by columns, correct?  I discovered that if
> you read a vector into GRID, it will read the matrix by rows.  Therefore, it
> seems that if you want to take a column vector in R and reshape it to a
> matrix in R, you should take the transpose of that column vector before
> forming it to a matrix.  Correct?
> 
>  
> 
> SO - let's say for example I generated a random uniform column vector 16x1
> which I was assuming to represent a 4x4 grid, and then I created a 4x4
> neighborhood for that grid, then a matrix from that neighborhood (wrk16),
> and calculated a spatial moving average:
> 
>  
> 
> grid1 -> 0.3 * wrk16 %*% grid + grid
> 
>  
> 
> The result is again a 16x1 column vector - now let's say I want to output
> this and read it into GRID - should I reshape it into a 4x4 matrix of the
> transpose of the grid1 column vector?
> 
>  
> 
> That's the best I can figure out.  Seems logical.  BUT, I opened up a grid
> whose values I knew, and the southwest corner of the source data was the
> northwest corner of the resulting grid.  If I don't do a transpose, the data
> are definitely not correct.
> 
>  
> 
> Thank you,
> 
> Darla Munroe
> 
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
-- 
Timothy H. Keitt
Section of Integrative Biology
University of Texas at Austin
http://www.keittlab.org/




More information about the R-sig-Geo mailing list