I have a geotiff that I read with rastertif <- terra::rast(x = tif) This produces the following warning:

[rast] the data in this file are rotated. Use 'rectify' to fix that

So I use rectify like this:

rastertif1 <- terra::rectify(rastertif)

This rotates the raster, but the rectangle is cropped - see the following plot: plot of rotated raster

The plot should show a completed rotated rectangle, but some parts on top and on the right hand side are cropped.

Any idea how the raster could be rotated while keeping the full extent?

  • I can't find a rotated raster and the help for rectify doesn't generate one for an example. Can you point us to one?
    – Spacedman
    Mar 16, 2022 at 9:44
  • 1
    Here is one: filemail.com/d/zerzradizidtoim
    – Mario
    Mar 16, 2022 at 9:49

1 Answer 1


I manually enlarged the bounding box of the SpatRaster like this:

e <- terra::ext(rastertif)
e$xmax <- e$xmax + 3000
e$ymax <- e$ymax + 3000

ext(rastertif) <- e

rastertif1 <- terra::rectify(rastertif, aoi = e)

Now, my raster is not cropped anymore after rectifying: rotated raster, not cropped

  • However, the transformation is extremely slow.
    – Mario
    Mar 16, 2022 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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