Or better still, provide a self contained example as below:


r1 <- raster(ncol=25, nrow=25, xmn=-50, xmx=50, ymn=-50, ymx=50)
r2 <- raster(ncol=25, nrow=25, xmn=-3.5, xmx=20, ymn=-3.5, ymx=20)
r1[]  <- 1:ncell(r1)
r2[]  <- 1:ncell(r2)
plot(r1)
plot(rasterToPolygons(r2), add=T)


# one approach
x <- resample(r1, r2, method='bilinear')


# what you asked for:
# first aggregate to apprixmately the same resolution
y <- aggregate(r2, floor(res(r1) / res(r2)), fun=mean)
# then resample
z <- resample(y, r1, method='bilinear')

plot(r1)
plot(rasterToPolygons(z), add=T)



On Mon, Sep 19, 2011 at 2:19 PM, steven mosher <moshersteven@gmail.com>wrote:

>  Hi Dr. Struve,
>
>  could you print out the characteristics of your rasters.
>
>  Just type the name of the raster at the console and cut and paste the
> output  in a mail.
>  I think your first step is probably going to be getting them in the
> same resolution..
>  Then match up the extents by cropping the larger one..  But if you
> show the details It will probably help folks give you a more direct
> answer..
>
> On Mon, Sep 19, 2011 at 2:13 PM, Struve,Juliane <jstruve@ufl.edu> wrote:
> >
> > Dear list,
> >
> > I have two rasters  with different origins, resolutions and extents.
> Raster 2 covers a sub-area of raster 1, which has a larger resolution and
> larger extent than raster 2. How can I change raster 2 so that every cell in
> raster 2 corresponds to another cell in raster 1 ? I have looked at
> different functions like mosaic() and overlay() but those functions do not
> seem to be applicable.
> >
> > Thank you very much for any suggestions.
> >
> > Juliane
> >
> >
> >
> >
> >        [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> >
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]

