Skip to content
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

system:time_start #342

Open
wilson733 opened this issue Jul 2, 2023 · 0 comments
Open

system:time_start #342

wilson733 opened this issue Jul 2, 2023 · 0 comments
Assignees
Labels
question Further information is requested

Comments

@wilson733
Copy link

wilson733 commented Jul 2, 2023

  • rgee version: 1.5.5
  • R version: 4.2.2
  • Operating System: windows 10

Description

I tried to to rename each image from sentinel 2 at format "YYYY-MM-dd". But the images dont change the format of the dates

What I Did

library(pacman)
p_load(rgee, reticulate, sf, sp, tidyverse, lubridate, DescTools)
ee_Initialize(drive = T)

archivo <-  choose.files(caption = "Seleccione archivo a estandatizar (shp, gpkg)",
                         multi = FALSE)
file_name <- paste0(tools::file_path_sans_ext(archivo),
                    '_AMBIENTADO_GCI.',
                    tools::file_ext(archivo))

poligono<-st_read(archivo, crs= 32721, stringsAsFactors = FALSE,
                  quiet = TRUE)

roi <-poligono %>%
  sf_as_ee()

#Creamos una coleccion de imagenes

collection_imag<- ee$ImageCollection("COPERNICUS/S2_HARMONIZED")$
  filterBounds(roi)$
  filter(ee$Filter$lt("CLOUD_COVERAGE_ASSESSMENT", 1))

#function to calculate satellite index

func_gci <-function(image){
  gci =image$expression(
    expression = 'NIR/GREEN-1',
    opt_map = list(
      'NIR' = image$select('B8'),
      'GREEN' = image$select('B3')
    )
  )
  return(image$addBands(gci$rename('GCI')))
}

collection_gci<- collection_imag$map(func_gci)$
  select("GCI")$map(function(image) {
    image$clip(roi)
  }
  )

rescale_rename <- function(image) {
  date <- ee$Date(image$get("system:time_start"))$format('YYYY_MM_dd')
  return(image$select('GCI')$rename(date))
}

gci_rescaled <- collection_gci$map(rescale_rename)

# Crear una grilla regular de 10 metros x 10 metros centrada en los polígonos

grid <- poligono%>%
  st_make_grid(what = "centers", cellsize = c(250, 250))%>%
  st_intersection(poligono)%>%
  sf_as_ee()
# Extraer los valores de la imagen apilada utilizando la grilla
valores <- ee_extract(gci_rescaled, grid, sf = T, scale = 20)
 X20230531T135709_20230531T140936_T21HTE_2023_05_31
@ambarja ambarja self-assigned this Sep 16, 2023
@ambarja ambarja added the question Further information is requested label Sep 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants