r-spatial / rgee

Google Earth Engine for R
https://r-spatial.github.io/rgee/
Other
677 stars 146 forks source link

problem with `ee_get_date_ic()` on `JRC/GSW1_3/YearlyHistory` ImageCollection #238

Closed zackarno closed 2 years ago

zackarno commented 2 years ago

Hello,

Hope you are doing well.

I am noticing an unexpected error with ee_get_date_ic() on the "JRC/GSW1_3/YearlyHistory" ImageCollection. See reprex below with in-line comments

library(rgee)
ee_Initialize()
#> -- rgee 1.1.2.9000 ---------------------------------- earthengine-api 0.1.295 -- 

#> --------------------------------------------------------------------------------
JRC_yearly <- ee$ImageCollection("JRC/GSW1_3/YearlyHistory")

# no issue printing - shows correct # of image (37)
JRC_yearly |> ee_print()
#> Registered S3 method overwritten by 'geojsonsf':
#>   method        from   
#>   print.geojson geojson
#> ------------------------------------------------ Earth Engine ImageCollection --
#> ImageCollection Metadata:
#>  - Class                      : ee$ImageCollection
#>  - Number of Images           : 37
#>  - Number of Properties       : 21
#>  - Number of Pixels*          : 3.301237e+13
#>  - Approximate size*          : 154.75 GB
#> Image Metadata (img_index = 0):
#>  - ID                         : JRC/GSW1_3/YearlyHistory/1984
#>  - system:time_start          : 1984-01-01
#>  - Number of Bands            : 1
#>  - Bands names                : waterClass
#>  - Number of Properties       : 5
#>  - Number of Pixels*          : 892226237778
#>  - Approximate size*          : 4.18 GB
#> Band Metadata (img_band = 'waterClass'):
#>  - EPSG (SRID)                : WGS 84 (EPSG:4326)
#>  - proj4string                : +proj=longlat +datum=WGS84 +no_defs
#>  - Geotransform               : 0.000269494585235856 0 -180.000014886978 0 -0.000269494585235856 78.0000872993992
#>  - Nominal scale (meters)     : 30
#>  - Dimensions                 : 1335834 667917
#>  - Number of Pixels           : 892226237778
#>  - Data type                  : INT
#>  - Approximate size           : 4.18 GB
#>  --------------------------------------------------------------------------------
#>  NOTE: (*) Properties calculated considering a constant  geotransform and data type.

# it looks like the image_id count is correct at 37, but somehow the dates are only being captured as 36 (looks
# like it is excluding the final year in the collection (2020) ?

JRC_yearly |> ee_get_date_ic()
#> Error in data.frame(id = image_id, time_start = time_start, stringsAsFactors = FALSE): arguments imply differing number of rows: 37, 36

Created on 2022-02-24 by the reprex package (v2.0.1)

zackarno commented 2 years ago

Not sure if this is helpful or not, but I realized the mismatch seems to go away after filtering the dates - see below

library(rgee)
ee_Initialize()
#> -- rgee 1.1.2.9000 ---------------------------------- earthengine-api 0.1.295 -- 

#> --------------------------------------------------------------------------------
JRC_yearly <- ee$ImageCollection("JRC/GSW1_3/YearlyHistory")

JRC_yearly$
  filterDate("2000-01-01","2010-12-31") |> 
  ee_get_date_ic()
#>                               id time_start
#> 1  JRC/GSW1_3/YearlyHistory/2000 2000-01-01
#> 2  JRC/GSW1_3/YearlyHistory/2001 2001-01-01
#> 3  JRC/GSW1_3/YearlyHistory/2002 2002-01-01
#> 4  JRC/GSW1_3/YearlyHistory/2003 2003-01-01
#> 5  JRC/GSW1_3/YearlyHistory/2004 2004-01-01
#> 6  JRC/GSW1_3/YearlyHistory/2005 2005-01-01
#> 7  JRC/GSW1_3/YearlyHistory/2006 2006-01-01
#> 8  JRC/GSW1_3/YearlyHistory/2007 2007-01-01
#> 9  JRC/GSW1_3/YearlyHistory/2008 2008-01-01
#> 10 JRC/GSW1_3/YearlyHistory/2009 2009-01-01
#> 11 JRC/GSW1_3/YearlyHistory/2010 2010-01-01

Created on 2022-02-24 by the reprex package (v2.0.1)

csaybar commented 2 years ago

Hi @zackarno deeply sorry for the very late reply. This is a bug that seems to happen on the Earth Engine side. I already reported in the GEE devs groups. You can find more details on the link below:

https://groups.google.com/g/google-earth-engine-developers/c/XUy27yH7XJI

btw, I added a more informative message, if the error occurs again in the future. Let me know if it works for you

Error in ee_get_date_ic(.) : Imposible to create a data.frame with:
system:id -> 36 [1984-01-01, ...., 2019-01-01]
system:time_stars -> 37 [JRC/GSW1_3/YearlyHistory/1984, ...., JRC/GSW1_3/YearlyHistory/2020] 

Very happy easter day :)

zackarno commented 2 years ago

Thanks @csaybar - the new message helps! Also good to know these types of issue can occur from the EE side.