r-spatial / discuss

a discussion repository: raise issues, or contribute!
54 stars 12 forks source link

rgee compatability with mapview #47

Closed jobbo90 closed 3 years ago

jobbo90 commented 3 years ago

I'm experiencing some issues lately with making the rgee library work with mapview, all examples used to work previously but I guess after some updates they no longer do. I reinstalled following all kinds of settings but can't seem to find the conflict.

 library(rgee)
 ee_Initialize()

 vizParams = list(
    bands = c("B5", "B4", "B3"),
    min = 0.05, max = 0.4, gamma = 1.4
  )

 collection<- ee$ImageCollection("LANDSAT/LT05/C01/T1_TOA")$
    filterBounds(ee$Geometry$Point(-55.54, 5.94))

 filtCollect <- collection$filterDate(as.character(as.Date(i)-1), 
                                       as.character(as.Date(i)+1))
 dates <- ee_get_date_ic(filtCollect, time_end = FALSE)

 Map$centerObject(filtCollect$first())
 first <- Map$addLayer(filtCollect$first(), vizParams, paste0('landsat: ',nearestDate))
stp1 <- st_sfc(st_point(c(-55.6, 6.02)), crs=4326)

stp2 <- st_sfc(st_point(c(-55.6, 6.02)), crs=4326)

So now the following hapens:

first  # as expected, the image is plotted
mapview(stp1) # also, as expected the point is plotted

Now try combining:
first + mapview(stp1) # throws error 1:

Error in +.EarthEngineMap(first, mapview(stp)) : right map is not an EarthEngineMap object

Here it gets confusing for me:

mapview(stp, first) works but mapview(first, stp) doesn't and throws me a whole other error:

Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘mapView’ for signature ‘"leaflet"’

because I was thinking this had to do with my python & earthegine environments I tried to reinstall, without succes of improving. Also because I didn't have the error before, I'm not sure where to proceed.

R version 3.6.3 (2020-02-29) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 17763)

Matrix products: default

locale: [1] LC_COLLATE=Dutch_Netherlands.1252 LC_CTYPE=Dutch_Netherlands.1252 LC_MONETARY=Dutch_Netherlands.1252 LC_NUMERIC=C
[5] LC_TIME=Dutch_Netherlands.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] viridis_0.5.1 viridisLite_0.3.0 RStoolbox_0.2.6 pointdensityP_0.3.5 scales_1.1.0 geosphere_1.5-10 testit_0.12
[8] car_3.0-7 carData_3.0-3 lubridate_1.7.4 EnvStats_2.4.0 zoo_1.8-7 jsonlite_1.7.2 sf_0.9-6
[15] qdapRegex_0.7.2 raster_3.3-13 rgdal_1.5-18 sp_1.4-4 forcats_0.5.0 stringr_1.4.0 dplyr_0.8.5
[22] purrr_0.3.3 tidyr_1.0.2 tibble_2.1.3 tidyverse_1.3.0 mapview_2.9.0 readr_1.4.0 ggplot2_3.3.2
[29] rgee_1.0.8.9999

loaded via a namespace (and not attached): [1] leafem_0.1.3 colorspace_1.4-1 ellipsis_0.3.0 class_7.3-16 rio_0.5.16 leaflet_2.0.3
[7] satellite_1.0.2 base64enc_0.1-3 fs_1.3.2 rstudioapi_0.11 prodlim_2019.11.13 xml2_1.2.5
[13] codetools_0.2-16 splines_3.6.3 doParallel_1.0.16 pROC_1.17.0.1 caret_6.0-86 broom_0.5.5
[19] dbplyr_1.4.2 png_0.1-7 rgeos_0.5-5 compiler_3.6.3 httr_1.4.1 backports_1.1.5
[25] assertthat_0.2.1 Matrix_1.2-18 cli_2.3.0 leaflet.providers_1.9.0 htmltools_0.4.0 tools_3.6.3
[31] gtable_0.3.0 glue_1.4.2 reshape2_1.4.3 Rcpp_1.0.6 cellranger_1.1.0 vctrs_0.2.4
[37] svglite_1.2.3.2 nlme_3.1-145 iterators_1.0.12 crosstalk_1.1.0.1 timeDate_3043.102 gower_0.2.2
[43] ps_1.5.0 openxlsx_4.1.4 rvest_0.3.5 lifecycle_0.2.0 XML_3.99-0.3 MASS_7.3-51.5
[49] ipred_0.9-9 hms_0.5.3 parallel_3.6.3 RColorBrewer_1.1-2 yaml_2.2.1 curl_4.3
[55] gridExtra_2.3 reticulate_1.18 gdtools_0.2.2 rpart_4.1-15 stringi_1.4.6 leafpop_0.0.6
[61] foreach_1.5.0 e1071_1.7-3 zip_2.0.4 lava_1.6.8.1 systemfonts_0.3.2 rlang_0.4.10
[67] pkgconfig_2.0.3 lattice_0.20-40 recipes_0.1.15 htmlwidgets_1.5.1 processx_3.4.5 tidyselect_1.1.0
[73] plyr_1.8.6 magrittr_2.0.1 R6_2.5.0 generics_0.1.0 DBI_1.1.0 pillar_1.4.3
[79] haven_2.2.0 foreign_0.8-76 withr_2.1.2 units_0.6-7 survival_3.1-11 abind_1.4-5
[85] nnet_7.3-13 modelr_0.1.6 crayon_1.4.1 uuid_0.1-4 KernSmooth_2.23-16 grid_3.6.3
[91] readxl_1.3.1 data.table_1.12.8 ModelMetrics_1.2.2.2 reprex_0.3.0 digest_0.6.25 classInt_0.4-3
[97] webshot_0.5.2 brew_1.0-6 stats4_3.6.3 munsell_0.5.0

ee_check() () Python version √ [Ok] C:/Users/5600944/AppData/Local/r-miniconda/envs/rgee/python.exe v3.9 () Python packages: √ [Ok] numpy √ [Ok] earthengine-api

Sys.getenv("EARTHENGINE_PYTHON") [1] "C:\Users\5600944\AppData\Local\r-miniconda\envs\rgee\python.exe" Sys.getenv("EARTHENGINE_ENV") [1] "rgee"

Any help is appreciated!

csaybar commented 3 years ago

Hi @jobbo90 can you open your issue here and close this one?, thanks! :)