ropensci / MODIStsp

An "R" package for automatic download and preprocessing of MODIS Land Products Time Series
https://docs.ropensci.org/MODIStsp
GNU General Public License v3.0
155 stars 50 forks source link

MODIStsp failed in to reproject from hdf to WGS84 #226

Closed cedlfc44 closed 3 years ago

cedlfc44 commented 3 years ago

HI: Im working into a researh, so i need to change crs from MODIS images during downloads. So, i working with MODIStsp function, but after finish to create hdf files in my cpu, a fail is occuring. BUT, when, i put #output_proj, download works fine.

thanks for your help

 Script
  rm(list=ls(all=TRUE))
  library(MODIStsp)  
  library(bench)
  library(sp)
  library(rgdal)   

  MTSP_fechas <- read.csv(file = "./fechas_imagenes_MODIS_tsp.txt")
  class(MTSP_fechas[1,1])

  for (ll in 1:24) {
  MODIStsp_get_prodlayers("M*D13Q1")
  spatial_file <- system.file("testdata/lakeshapes/cercado.shp", package = "MODIStsp")

  MTSP_descarga<-MODIStsp(gui             = FALSE,
          spatmeth        = "file",
          spafile         = spatial_file,  
          out_folder      = "$tempdir",
          selprod         = "Vegetation Indexes_16Days_250m (M*D13Q1)",
          bandsel         = c("EVI"),
          output_proj = st_as_text(st_crs(4326)),
          # output_proj     = "EPSG:4326",
          # output_proj     = "+proj=longlat +datum=WGS84 +no_defs",
          user            = "********" ,
          password        = "**********",
          start_date      = MTSP_fechas[ll,1],  
          end_date        = MTSP_fechas[ll,1],
          verbose         = FALSE)

  out_fold <- file.path(tempdir(), "MODIStsp/cercado/VI_16Days_250m_v6/") 

FAIL Error in gdal_utils("buildvrt", gdalfile, output.vrt, opts) : gdal_utils buildvrt: an error occured Además: Warning message: In CPL_gdalbuildvrt(source, destination, options, oo, quiet) : GDAL Error 5: Invalid user extent

ranghetti commented 3 years ago

Hi, can you attach the shapefile cercado.shp (among with all the accessoriy files) and paste the content of file fechas_imagenes_MODIS_tsp.txt? Moreover, provide the output of:

sessionInfo()
packageVersion("sen2r")
cedlfc44 commented 3 years ago

Hi: this is fechas_imagenes_MODIS_tsp.txt

Fechas_MODIS
2015.01.01
2015.01.17
2015.02.02
2015.02.18
2015.03.06
2015.03.22
2015.04.07
2015.04.23
2015.05.09
2015.05.25
2015.06.10
2015.06.26
2015.07.12

sessionInfo() R version 4.0.3 (2020-10-10) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18363)

Matrix products: default

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

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

other attached packages: [1] sen2r_1.3.9 sf_0.9-6 rgdal_1.5-18 sp_1.4-4 bench_1.1.1 MODIStsp_2.0.4

loaded via a namespace (and not attached): [1] gdalUtilities_1.1.0 zoo_1.8-8 tidyselect_1.1.0 purrr_0.3.4
[5] lattice_0.20-41 V8_3.2.0 vctrs_0.3.4 generics_0.0.2
[9] stars_0.4-4 XML_3.99-0.5 rlang_0.4.8 e1071_1.7-4
[13] pillar_1.4.6 foreign_0.8-80 glue_1.4.2 httpcode_0.3.0
[17] DBI_1.1.0 foreach_1.5.0 lifecycle_0.2.0 stringr_1.4.0.9000 [21] geojsonio_0.9.2 rgeos_0.5-3 raster_3.3-13 RcppTOML_0.1.7
[25] codetools_0.2-16 doParallel_1.0.15 maptools_1.0-1 parallel_4.0.3
[29] curl_4.3 class_7.3-17 xts_0.12-0 Rcpp_1.0.5
[33] KernSmooth_2.23-17 classInt_0.4-3 lwgeom_0.2-5 jsonlite_1.7.1
[37] abind_1.4-5 stringi_1.5.3 dplyr_1.0.0 grid_4.0.3
[41] jqr_1.1.0 tools_4.0.3 bitops_1.0-6 magrittr_1.5
[45] lazyeval_0.2.2 geojson_0.3.4 tibble_3.0.4 crul_1.0.0
[49] crayon_1.3.4 pkgconfig_2.0.3 ellipsis_0.3.1 data.table_1.12.8
[53] xml2_1.3.2 assertthat_0.2.1 httr_1.4.2 rstudioapi_0.11
[57] iterators_1.0.12 R6_2.5.0 units_0.6-7 compiler_4.0.3

packageVersion("sen2r") [1] ‘1.3.9’

cedlfc44 commented 3 years ago

Cercado shape cercado.zip

ranghetti commented 3 years ago

Sorry for the long waiting. It should be fixed, but I cannon test it since NASA server is currently down. Please install the develop package version with the command below, retry your code and let me know if the bug was fixed.

ranghetti commented 3 years ago

Sorry, I forgot to write the command:

install.packages("remotes")
remotes::install_github("ropensci/MODIStsp", ref = "devel")
cedlfc44 commented 3 years ago

ok, thanks im going to try right now

cedlfc44 commented 3 years ago

hi: MODIStsp command is working perfectly. bug is fixed. thanks for your help