Message-ID: <1358971061.36934.YahooMailNeo@web121902.mail.ne1.yahoo.com>
Date: 2013-01-23T19:57:41Z
From: Thiago V. dos Santos
Subject: See coordinates vector in raster
In-Reply-To: <CANVKczMBPc1V2Lh9ZJqpy+7F74WmdQJ-ShaTqVe49WfA3F8K_g@mail.gmail.com>
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