In R I'm trying to make a RasterStack of RasterLayers, they all have the same format, the only difference is that one of them is a solo raster and the others are bioclimatic variables. The soil layer had a resolution of ~ 1km and was redesigned to 5km to align with the others.
closed as off-topic by PolyGeo♦ Apr 17 at 20:17
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "When seeking help to debug/write/improve code always provide the desired behavior, a specific problem/error and the shortest code (as formatted text, not pictures) needed to reproduce it in the question body. Providing a clear problem statement and a code attempt helps others to help you." – PolyGeo
Firstly, you need them to be the same CRS and resolution in order to stack them. For this. Assuming your 5k raster also has a bigger extent for the purposes of this example, you can use
bigger_raster <- projectRaster(raster5k, smaller_raster)
Now, if your extents are still off - you'll need to use
raster::crop() to fix this.
new_raster <- crop(bigger_raster,smaller_raster)
bigger_raster will line up with