0

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
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Which Software? – MrXsquared Apr 17 at 17:12
  • Please read our FAQ on how to ask a good question. We have no idea on the software that you are using, data format or specific information on your rasters (rows, columns, bounding extents). So, any answer is, at best, a guess. Please edit your questions to add some specifics as well as a tag that specifies what software environment you are working in. – Jeffrey Evans Apr 17 at 18:08
  • @Jackson, you are making some huge assumptions that this is an R specific question. The term and concept "raster stack" applies to numerous software including the "big box" brands such as ERDAS, ESRI, ENVI, and alignment problems would be just as relevant. Admittedly, this is likely R related but, editing a post without knowing that this was the case is jumping-the-gun a bit and should be avoided. There is nothing in the original post that indicates R! – Jeffrey Evans Apr 17 at 19:45
  • @Jeffrey noted. I made the edit as compareRaster is a common/standard function in R (and noted in the title of the post), I agree that I made an assumption (though I would not call it ‘huge’). – Jackson Apr 18 at 0:34
  • @Jackson, I would note that there are "compareRaster" functions in ENVI-IDL and ERDAS-EML. Yes, exactly the same function call name. – Jeffrey Evans Apr 18 at 14:22
1

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 raster::projectRaster():

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)

Now bigger_raster will line up with smaller_raster.

Not the answer you're looking for? Browse other questions tagged or ask your own question.