mikejohnson51 / climateR

An R 📦 for getting point and gridded climate data by AOI
https://mikejohnson51.github.io/climateR/
MIT License
165 stars 40 forks source link

Problem download MODIS data #95

Open gpandradep opened 4 months ago

gpandradep commented 4 months ago

Hi @mikejohnson51 ,

Thank you very much for developing the package, it has been very useful for me. I have an error downloading MODIS data that I have not been able to solve. This is the code I am using

library(tidyverse)
library(climateR)
library(AOI)
library(bioclima)
library(sf)
library(sp)
library(mapview)

# Get all Texas area
Texas <- aoi_get(state = c("TX"))
#Just to check
Texas %>% st_as_sf() %>% aoi_map(returnMap = T)

modis <-  getMODIS(
  AOI       = Texas,
  asset    = 'MOD13A2.061',
 # ID= "MODIS",
 varname   = c("_1_km_16_days_EVI", "_1_km_16_days_NDVI"),
  startDate = "2023-06-20",
  endDate = "2023-12-19")

This is the error I get when I run the getMODIS function:

Error in fix.by(by.x, x) : 'by' must specify a uniquely valid column

I have used other functions like getGridMET and they have worked fine using the same area and dates, so I don't understand what could be happening.

climdata <- getGridMET(AOI= Texas,
                   varname = c("vs", "pr", "tmmx"),
                   startDate = "2023-06-20",
                   endDate = "2023-12-19")

Thanks,

sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22631)

Matrix products: default

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

other attached packages:
 [1] here_0.1-11     mapview_2.11.2  sp_1.4-6        sf_1.0-7        bioclima_0.0.2  terra_1.7-23   
 [7] AOI_0.3.0       climateR_0.3.4  lubridate_1.9.2 forcats_1.0.0   stringr_1.5.0   dplyr_1.1.0    
[13] purrr_1.0.1     readr_2.1.4     tidyr_1.3.0     tibble_3.1.8    ggplot2_3.4.1   tidyverse_2.0.0

loaded via a namespace (and not attached):
 [1] httr_1.4.5              rnaturalearth_0.1.0     bit64_4.0.5             jsonlite_1.8.4         
 [5] assertthat_0.2.1        stats4_4.1.0            yaml_2.3.5              globals_0.16.2         
 [9] pillar_1.9.0            lattice_0.20-44         glue_1.6.2              digest_0.6.31          
[13] rvest_1.0.3             leaflet.providers_1.9.0 colorspace_2.1-0        htmltools_0.5.2        
[17] pkgconfig_2.0.3         raster_3.6-20           gifski_1.6.6-1          listenv_0.8.0          
[21] scales_1.2.1            satellite_1.0.4         tzdb_0.4.0              timechange_0.2.0       
[25] proxy_0.4-26            generics_0.1.3          withr_2.5.0             cli_3.6.0              
[29] fipio_1.1.2             magrittr_2.0.3          future_1.32.0           fansi_0.5.0            
[33] parallelly_1.35.0       xml2_1.3.3              class_7.3-19            tools_4.1.0            
[37] hms_1.1.3               lifecycle_1.0.3         munsell_0.5.0           compiler_4.1.0         
[41] e1071_1.7-9             RNetCDF_2.6-2           rlang_1.0.6             classInt_0.4-3         
[45] units_0.8-0             grid_4.1.0              rstudioapi_0.14         htmlwidgets_1.5.4      
[49] crosstalk_1.2.0         leafem_0.1.6            base64enc_0.1-3         arrow_15.0.1           
[53] gtable_0.3.1            codetools_0.2-18        DBI_1.1.2               R6_2.5.1               
[57] ncmeta_0.3.6            fastmap_1.1.0           future.apply_1.8.1      bit_4.0.5              
[61] utf8_1.2.2              rprojroot_2.0.3         fastmatch_1.1-3         tidygeocoder_1.0.5     
[65] KernSmooth_2.23-20      stringi_1.7.12          parallel_4.1.0          Rcpp_1.0.10            
[69] vctrs_0.5.2             png_0.1-7               leaflet_2.0.4.1         tidyselect_1.2.0