-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reducing image collection to image returns only one value per band #214
Comments
Hi @DavidDHofmann you have to define the scale argument: reduced2 <- ee_as_raster(reduced, dsn = "reduced.tif", scale = 1000) The warnings appear because GEE retrieved your query using positive y spacing and Warning
In .rasterFromGDAL(x, band = band, objecttype, ...) :
data seems flipped. Consider using: flip(x, direction='y') |
Hi @csaybar |
Hi @DavidDHofmann :) In fact, you can!. The issue is that after applying a reducer ee_print(collection) ee_print(collection$mean()) It is a consequence of GEE lazy evaluation. The client library API does not know if after applying your "selected reducer" (mean) you are conserving the image geometric properties it's something that will be evaluated at the server-side. My advice would be to store the properties before the reducer. # Load required packages
library(rgee)
library(terra)
# Init
ee_Initialize()
# Specify an area of interest
aoi <- ee$Geometry$Polygon(
list(
c(23.4976149678726, -19.649075296214)
, c(23.4976149678726, -19.2680589256603)
, c(23.93394016641, -19.2680589256603)
, c(23.93394016641, -19.649075296214)
)
)
# Query sentinel 2 data
collection <- ee$ImageCollection("COPERNICUS/S2_SR")$
filterDate("2021-04-05", "2021-04-06")$
filterBounds(aoi)$
select("B2")
collection$first()$projection()$nominalScale()$getInfo()
#10 |
Ah okey cool, I wasn't aware of this. This also explains why the estimated image size becomes unreasonably small after applying the reudcer. Thank you very much for the clarification. The download works perfectly fine now :) |
At submit an issue, please attached the following information of your
rgee
session:Description
Hi there!
I'm trying to download Sentinel-2 data for a specific date. For the date and area of interest, Earth Engine returns an image-collection with two images that overlap in extent. I then try to reduce the collection into a single image using a median-reducer. Ultimately, I clip the reduced image to my area of interest and download the data. Oddly enough,
ee_print(reduced)
shows that the image only contains one pixel per band. Nevertheless, the image looks fine when displayed on the map. Only when downloaded, the bands contain only one value per band. To me, it seems that the reducer does not apply the median per pixel across bands, but across the entire band. The coordinates of the final image also do not exactly match my specified aoi and I get a warning after download saying:I'm not quite sure what I'm doing wrong. Any suggestions?
What I Did
plot(r)
The text was updated successfully, but these errors were encountered: