[R-sig-Geo] How to extract the index (i, j) row and column from a raster?

Lionel Hertzog s6lihert at uni-bonn.de
Wed Jun 19 13:00:01 CEST 2013


The easiest way is to use the function 'values' which return the values 
of a raster row by row:

r<-raster(nrows=10,ncols=10)
r[]<-rnorm(100)
data<-data.frame(X=rep(1:10,each=10),Y=rep(1:10,10),Z=values(r))
head(data)

Cheers,
Lionel

On 19/06/2013 12:42, Alex wrote:
> Please, I would like to create a file with the following information from a
> raster:
> - The position (i, j) of each cell, and the value represented in pixel.
> Composing a matrix X, Y, Z.
> At the end, I have the intention to turn this array into a polygon
> shapefile.
> Is there any function for this in R?
> I thank you,
> Alex Santos
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



More information about the R-sig-Geo mailing list