[R-sig-Geo] raster() and mixed-projection/resolution files

Robert J. Hijmans r.hijmans at gmail.com
Tue May 25 05:39:35 CEST 2010


Dear Jonathan,

It depends. In the best case you can change the resolution of raster2
with 'aggregate' or 'disaggregate' (or a combination); and change its
extent with 'expand' or 'crop'.

In other cases, for example if the origin of the rasters also differ,
it may be necessary to resort to 'resample' to change the origin (and
perhaps cells size and extent at the same time).

Some raster algebra will actually work for rasters with different
extents, as long as they overlap at least partly, and their origin and
resolution are the same (the extent of the raster returned is the
intersect of the input rasters)

Robert


On Mon, May 24, 2010 at 7:35 PM, Jonathan Greenberg
<greenberg at ucdavis.edu> wrote:
> R-sig-geo'ers:
>
> Given two rasters of differing resolutions, extents, and cell sizes,
> what is the most efficient way to do some level of raster algebra on
> the files, e.g.:
>
> raster1=raster(file1)
> raster2=raster(file2)
>
> I would like to add raster1 + raster2 and have the output be the
> extent, cell size and projection of file1.   My understanding is
> raster()'s map algebra requires the same size/projection of the
> inputs, correct?  Thanks!
>
> --j
>



More information about the R-sig-Geo mailing list