1

I am trying to learn the stars package in R, however I am working with data that is very high resolution. I know that that within the Raster package, doing the following:

aggregate(raster, factor = 4)

Would transform the raster from one that had a 30x30m resolution to one which was 120x120m, for example. Is there a similar way to perform this in stars? When I attempt the aggregate function on a stars object, I get the following error:

Error in inherits(by, "stars") : argument "by" is missing, with no default

However, I'm not certain what to aggregate by in this case, as I'm really just trying to reduce the overall resolution.

Andrew
  • 41
  • 3

2 Answers2

0

I think st_warp() is able to do this. See here

AndersK
  • 31
  • 5
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/33648874) – jpsmith Jan 22 '23 at 23:16
0

You can use terra methods like this

library(terra)
r <- rast(raster)

a <- aggregate(r, factor = 4)

s <- st_as_stars(a)
Robert Hijmans
  • 40,301
  • 4
  • 55
  • 63