See coordinates vector in raster
Michael and Barry, Thank you for the tips. Both worked like a charm! Regards, Thiago. ----- Original Message ----- From: Barry Rowlingson <b.rowlingson at lancaster.ac.uk> To: Michael Sumner <mdsumner at gmail.com> Cc: Thiago V. dos Santos <thi_veloso at yahoo.com.br>; R-SIG list <r-sig-geo at r-project.org> Sent: Wednesday, January 23, 2013 7:33 AM Subject: Re: [R-sig-Geo] See coordinates vector in raster
On Wed, Jan 23, 2013 at 12:06 AM, Michael Sumner <mdsumner at gmail.com> wrote:
You can just do xy <- coordinates(r1) which gives a 2-column matrix with lon <- xy[,1] lat <- xy[,2] Note that for largish rasters this is a considerable amount of data, and it's mostly all redundant since you can generate it from the resolution and extent, so you might need to consider other options.
Better to use xFromCol and yFromRow! xFromCol(r,1:ncol(r)) yFromRow(r,1:nrow(r)) should do the job. Barry