Skip to content

Commit

Permalink
minor update for ee_Init
Browse files Browse the repository at this point in the history
  • Loading branch information
kongdd committed Mar 22, 2024
1 parent 79b59a8 commit f153a12
Show file tree
Hide file tree
Showing 11 changed files with 294 additions and 90 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ data-raw
# examples/
*.nc
libs
*.vdoc.r
*.csv
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ Remotes:
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.1
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export(dndate_start)
export(drive_csv_clean)
export(ee)
export(ee2r)
export(ee_Init)
export(ee_Initialize)
export(ee_aggregate)
export(ee_aggregate_array)
Expand Down Expand Up @@ -60,13 +61,17 @@ import(glue)
import(rgee)
import(stringr)
importFrom(dplyr,mutate)
importFrom(glue,glue)
importFrom(grDevices,col2rgb)
importFrom(grDevices,rgb)
importFrom(lubridate,make_date)
importFrom(magrittr,"%<>%")
importFrom(magrittr,"%>%")
importFrom(magrittr,add)
importFrom(magrittr,set_names)
importFrom(rgee,Map)
importFrom(rgee,ee)
importFrom(rgee,ee_Initialize)
importFrom(stats,setNames)
importFrom(tidyr,matches)
importFrom(tidyr,pivot_longer)
Expand Down
5 changes: 4 additions & 1 deletion R/ee_init.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' }
#' @seealso [rgee::ee_Initialize()]
#' @export
ee_init <- function(drive=FALSE, ...) {
ee_Init <- function(drive=FALSE, ...) {
tryCatch({
ee$Image(1)
invisible()
Expand All @@ -19,3 +19,6 @@ ee_init <- function(drive=FALSE, ...) {
# message(sprintf('%s', e$message))
})
}

#' @export
ee_init = ee_Init
3 changes: 3 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
output: github_document
---

-`conda install earthengine-api=0.1.370`
-`rgee: 0.1.7`

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r, include = FALSE}
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
[![codecov](https://codecov.io/gh/rpkgs/rgee2/branch/master/graph/badge.svg)](https://app.codecov.io/gh/rpkgs/rgee2)
<!-- badges: end -->

- `conda install earthengine-api=0.1.370`
- `rgee: 0.1.7`


## Installation

Expand Down
6 changes: 3 additions & 3 deletions man/ee_init.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions scripts/BEPS/ee_extract_02_st212_MODIS.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
> GEE限制变多: no more than 5000 bands
```{r}
library(rgee)
library(rgee2)
library(rfluxnet)
library(sf)
library(sf2)
library(Ipaper)
ee_Initialize(drive = TRUE)
```

```{r}
# st = st_flux212[1:10, .(site, lon, lat)]
# st = data.frame(site='CUG', lon = 114.61, lat = 30.4595)
st = data.frame(site=57493, lon = 114.3197, lat = 30.35)
sp <- df2sf(st)
imgcol = ee$ImageCollection$Dataset$MODIS_061_MOD15A2H
proj = ee_get_proj(imgcol)
scale = proj$scale # scale should lte prj.scale
# scale = 463.3127
# sp_2 = st_point_buffer(st, scale = scale, half_win = 1) # -half_win: half_win
# sp_5 = st_point_buffer(st, scale = scale, half_win = 2)
```

```{r}
# col <- ee$ImageCollection("MODIS/061/MCD12Q1")$select(0)
# df = ee_extract(col, sp, via = "getInfo", lazy = FALSE, scale = 500)
# df
# rfluxnet::IGBP_006
images = list(
CI = "users/kongdd/BEPS/CI_240X_1Y_V1",
soil_type = "OpenLandMap/SOL/SOL_TEXTURE-CLASS_USDA-TT_M/v02",
soil_water = "OpenLandMap/SOL/SOL_WATERCONTENT-33KPA_USDA-4B1C_M/v01",
soil_buld = "OpenLandMap/SOL/SOL_BULKDENS-FINEEARTH_USDA-4A1H_M/v02",
soil_pH = "OpenLandMap/SOL/SOL_PH-H2O_USDA-4C1A2A_M/v02",
soil_clay = "OpenLandMap/SOL/SOL_CLAY-WFRACTION_USDA-3A1A1A_M/v02",
soil_sand = "OpenLandMap/SOL/SOL_SAND-WFRACTION_USDA-3A1A1A_M/v02"
)
# d = ee_extract(images$CI, sp, via = "getInfo", lazy = FALSE, scale = 500)
ee_extract_images <- function(sp) {
lst = foreach(img = images, i = icount()) %do% {
img = ee$Image(img)
ee_extract(img, sp, via = "getInfo", lazy = FALSE, scale = 500)
}
}
CI = lst[[1]]
lst[2:length(lst)] |> melt_list("varname") |>
relocate(b30, b60, .after = "b10")
# CI
# Soil type
# Soil water content at 33kPa (field capacity)
# img = ee$Image(images$soil_type)
df = ee_extract_images(sp)
```

<https://developers.google.com/earth-engine/datasets/catalog/OpenLandMap_SOL_SOL_WATERCONTENT-33KPA_USDA-4B1C_M_v01>

76 changes: 0 additions & 76 deletions scripts/Extractor/ee_extract_02_st212_MODIS.R

This file was deleted.

Loading

0 comments on commit f153a12

Please sign in to comment.