TransWikia.com

How to adjust the resolution of one raster to the resolution of another raster

Geographic Information Systems Asked by Nadav Bendavid on December 19, 2020

I have two rasters, both showing forest cover. I eventually want to use one to mask the other, so I’m trying to get them to the same extent and resolution. I matched the extent by simply cropping one raster to the extent of the other using extent() and crop().

So now I have these two rasters

mang2000crop and loss

> mang2000crop  
class      : RasterLayer  
dimensions : 144000, 144000, 2.0736e+10  (nrow, ncol, ncell)  
resolution : 0.000277778, 0.000277778  (x, y)  
extent     : -20, 20.00003, -19.99992, 20.00011  (xmin, xmax, ymin, ymax)  
crs        : +proj=longlat +datum=WGS84 +no_defs  
source     : C:/Users/user/Documents/r_files/mang2000crop.tif  
names      : mang2000crop  
values     : 0, 955  (min, max)

> loss
class      : RasterLayer 
dimensions : 160000, 160000, 2.56e+10  (nrow, ncol, ncell)
resolution : 0.00025, 0.00025  (x, y)
extent     : -20, 20, -20, 20  (xmin, xmax, ymin, ymax)
crs        : +proj=longlat +datum=WGS84 +no_defs 
source     : C:/Users/user/Documents/r_files/Hansen_loss_total.tif 
names      : Hansen_loss_total 
values     : 0, 19  (min, max)

How can I adjust the resolution of mang2000crop to the resolution of loss? (so from 0.000277778, 0.000277778 to 0.00025, 0.00025)

Also, is there a quick way to adjust the very slight difference in extent?

One Answer

You can use crop but normally you should not use extent to change a georeference. Then allows you to move the data to where you want it, but it is no longer valid.

You can use resample like this

mang2000crop2 <- resample(mang2000crop, loss)

Answered by Robert Hijmans on December 19, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP