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

Michael Sumner mdsumner at gmail.com
Thu Jan 24 02:17:23 CET 2013


"Better" depends on what was required, which wasn't specified - all
the coordinates, or just 1-d arrays of the unique ones. Our answers
are totally different, Thiago I trust that you see the difference?

It would be good if xFromCol / yFromRow had defaults for their second
argument to return all if colnr/rownr are not specified.

Robert: do you think that's a reasonable modification?  (Or are their
already other functions for that?) :)

Cheers, Mike.

On Thu, Jan 24, 2013 at 12:33 AM, Barry Rowlingson
<b.rowlingson at lancaster.ac.uk> wrote:
> 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



-- 
Michael Sumner
Hobart, Australia
e-mail: mdsumner at gmail.com



More information about the R-sig-Geo mailing list