[R-sig-Geo] Combining different rasters
steven mosher
moshersteven at gmail.com
Tue Sep 20 01:10:09 CEST 2011
Thanks robert.. I have a similar problem with two rasters where one
has a .01 degree
resolution and the other is 30 arc second (.008333) both with
different extents..and I was puzzling over that just as Juliane
posted.. synchronicity..
have a great day
On Mon, Sep 19, 2011 at 4:01 PM, Robert J. Hijmans <r.hijmans at gmail.com> wrote:
> 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 at 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 at 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 at r-project.org
>> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>> >
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
>
More information about the R-sig-Geo
mailing list