[R-sig-Geo] SpatialPixel and SpatialPoints Overlay output

Roger Bivand Roger.Bivand at nhh.no
Fri Oct 26 14:51:34 CEST 2007


On Fri, 26 Oct 2007, Michal Gallay wrote:

> Hello R User's,
>
> I am struggling with overlaying 2 rasters datasets. Both were ASCII grids
> and loaded via read.asciigrid. One as SpatialPixelDataFrame and another
> converted to SpatialPointsDataFrame.
>
> The are shifted with respect to each other and the aim is to get the values
> from raster1 in the overaly region with raster2. However, the overaly does
> not give the values which are in raster1 at data, but the values'
> order(position in the vector).
>
> Could anyone advise why is that? Is there a simple way how to actually clip
> them according to the overlay region?

In general (not just in this context, but for many non-spatial objects 
too), use the [ operator: raster1 at data[o,] to extract the values as a data 
frame for the o indices returned by overlay(), or (most likely) 
raster1 at data[o, 1] as a vector.

Roger

>
> Thank you very much.
>
> Regards,
>
> Michal
>
>
>
>
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-sig-Geo mailing list