Michael,

Specifically to my problem, Barry's solution what was I expected. But your suggestion is also useful and I wrote it down as well.

It would be nice to have a getCoords function in raster package to use in conjuction with rasterFromXYZ! 

Regards,
Thiago.


________________________________
 From: Michael Sumner <mdsumner@gmail.com>
To: R-SIG list <r-sig-geo@r-project.org>; Robert Hijmans <r.hijmans@gmail.com> 

lingson@lancaster.ac.uk> 
Sent: Wednesday, January 23, 2013 7:17 PM
Subject: Re: [R-sig-Geo] See coordinates vector in raster

"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@lancaster.ac.uk> wrote:
> On Wed, Jan 23, 2013 at 12:06 AM, Michael Sumner <mdsumner@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.
>
[[elided Yahoo spam]]
>
> xFromCol(r,1:ncol(r))
> yFromRow(r,1:nrow(r))
>
>  should do the job.
>
> Barry



-- 
Michael Sumner
Hobart, Australia
e-mail: mdsumner@gmail.com
	[[alternative HTML version deleted]]

