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

Rafael Wüest rafael.wueest at wsl.ch
Wed Jun 19 14:30:55 CEST 2013


Well, if the ultimate aim is to build a polygon from a raster, I suggest you look at

library(raster)
?rasterToPolygons

Rafael

On 19.06.2013, at 13:00, Lionel Hertzog <s6lihert at uni-bonn.de> wrote:

> 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
>> 
> 
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



--
Rafael Wüest
Swiss Federal Research Institute WSL
Zürcherstrasse 111
8903 Birmensdorf
Switzerland

+41 44 7392126
rafael.wueest at wsl.ch
http://www.wsl.ch/info/mitarbeitende/wueest/index_EN



More information about the R-sig-Geo mailing list