[R-sig-Geo] See coordinates vector in raster

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Wed Jan 23 14:33:51 CET 2013


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



More information about the R-sig-Geo mailing list