<html style="direction: ltr;">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style id="bidiui-paragraph-margins" type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
</head>
<body bidimailui-charset-is-forced="true" style="direction: ltr;">
<p><br>
</p>
<div class="moz-cite-prefix">On 08/09/2020 19:33, Julian M. Burgos
wrote:<br>
</div>
<blockquote type="cite" cite="mid:xgz363sw7nf.fsf@hafogvatn.is">
<pre class="moz-quote-pre" wrap="">Dear all,
The raster package has the raster::aggregate function that can be used to reduce the resolution of a raster by aggregating cells by a specific factor. For example, this reduces the resolution of the L7_ETMs.tif raster by a factor of 10:
library(raster)
rst1 <- raster(system.file("tif/L7_ETMs.tif", package = "stars"))
rst2 <- aggregate(rst1, fact = 10, fun = mean)
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">res(rst1)
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">[1] 28.5 28.5
</pre>
<blockquote type="cite">
<pre class="moz-quote-pre" wrap="">res(rst2)
</pre>
</blockquote>
<pre class="moz-quote-pre" wrap="">[1] 285 285
I am trying to do the same thing with a stars object. The stars package has the stars::aggregate function, but for spatial aggregation it takes an object of class sf or sfc, so it is meant to be used for aggregation over polygons. I could do something like this:
</pre>
</blockquote>
<p>Probably st_warp() is what you want:</p>
<p><br>
</p>
<p>l7_file = system.file("tif/L7_ETMs.tif", package = "stars") <br>
l7 = read_stars(l7_file)</p>
<p>l7_lowres = st_warp(src = l7, cellsize = c(90, 90), crs =
st_crs(l7))<br>
</p>
<p><br>
</p>
<p>stars::st_dimensions(l7)<br>
from to offset delta refsys point
values <br>
x 1 349 288776 28.5 +proj=utm +zone=25 +south... FALSE
NULL [x]<br>
y 1 352 9120761 -28.5 +proj=utm +zone=25 +south... FALSE
NULL [y]<br>
band 1 6 NA NA NA NA
NULL </p>
<p><br>
</p>
<p>stars::st_dimensions(l7_lowres)<br>
from to offset delta refsys point
values <br>
x 1 111 288776 90 +proj=utm +zone=25 +south... NA
NULL [x]<br>
y 1 112 9120761 -90 +proj=utm +zone=25 +south... NA
NULL [y]<br>
band 1 6 NA NA NA NA
NULL <br>
</p>
<br>
<pre class="moz-signature" cols="72">--
Micha Silver
Ben Gurion Univ.
Sde Boker, Remote Sensing Lab
cell: +972-523-665918
<a class="moz-txt-link-freetext" href="https://orcid.org/0000-0002-1128-1325">https://orcid.org/0000-0002-1128-1325</a></pre>
</body>
</html>