In the vignette("simple_workflow"), we have imported data :

  • from several collections (MOD11A1.006, GPM_L3/GPM_3IMERGDF.06, SMAP/SPL3SMP_E.003) ;
  • over one single region of interest (ROI) ;
  • for one single time frame of interest (2017-01-01 to 2017-01-30).

So far so good, but what if we need multiple regions of interest, and / or multiple time frames of interest ? Those case are likely to happen, for instance :

  • multiple time frames of interest : we have spatiotemporal sampling data - e.g. species occurence - that were collected over a large time frame and we want to study how local past environmental / climatic conditions influence the occurence ;
  • multiple regions of interest : we want to compare two areas in terms of their environmental or climatic conditions.

We could use for loops or related stuff to do the job. However, this would not be very optimized. In this vignette, we explain why and we show how to optimize the data import in the case of multiple time frames. Multiple regions of interest will be dealt in another vignette. Let’s start !

Setup the region and time range of interest

First we call the useful packages and we the script : define ROI and time frames (here, for the example, the month of january for each year from 2016 to 2019)

require(opendapr)
require(sf)
require(purrr)
require(raster)
require(ncdf4)
require(magrittr)
# Set ROI and time range of interest
roi <- st_as_sf(data.frame(geom="POLYGON ((-5.82 9.54, -5.42 9.55, -5.41 8.84, -5.81 8.84, -5.82 9.54))"),wkt="geom",crs = 4326)
time_ranges <- list(as.Date(c("2016-01-01","2016-01-31")),
                    as.Date(c("2017-01-01","2017-01-31")),
                    as.Date(c("2018-01-01","2018-01-31")),
                    as.Date(c("2019-01-01","2019-01-31")))

Login to EOSDIS Earthdata

And we login to EOSDIS Earthdata with our credentials. To create an account go to : https://urs.earthdata.nasa.gov/.

Get the OPeNDAP URLs of the data to download

Of course, we could loop over the odr_get_url() with the time ranges of interest, and get the data. However, the odr_get_url() function does query the OPeNDAP servers each time it is called. This query internally imports various data, including OPeNDAP time, latitude and longitude vectors, and this process takes some time. In case you loop over the function for the same ROI and multiple time frames of interest, it will import again and again the same data, which is quite useless.

Here is where the function odr_get_opt_param() comes into the game. For a given collection and ROI, this function queries the OPeNDAP server and retrieves the information that we were mentionning in the previous paragraph. This function is actually run within the odr_get_url() function, but its output can also be provided as input parameter opt_param of odr_get_url(). If odr_get_url() is queried multiple times for the same couple {collection, ROI}, it is hence more efficient to pre-compute only once the argument opt_param using odr_get_opt_param() and to further provide it to odr_get_url() within a for loop or e.g. a purrr::map() function.

To summarize : when we have multiple time frames of interest, prior to executing odr_get_url() we retrieve the opt_param parameter for each collection and roi with odr_get_opt_param() :

And we get our URLs, using a purrr::map() function over our time frames of interest and setting the opt_param parameter in odr_get_url() :

urls_mod11a1 <- map(.x = time_ranges, ~odr_get_url(
  collection = "MOD11A1.006",
  variables = c("LST_Day_1km","LST_Night_1km","QC_Day","QC_Night"),
  roi = roi,
  time_range = .x,
  opt_param = opt_param_mod11a1)
  )
#> Building the URLs...
#> OK
#> Building the URLs...
#> OK
#> Building the URLs...
#> OK
#> Building the URLs...
#> OK

urls_gpm <- map(.x = time_ranges, ~odr_get_url(
  collection = "GPM_3IMERGDF.06",
  variables = c("precipitationCal","precipitationCal_cnt"),
  roi = roi,
  time_range = .x,
  opt_param = opt_param_gpm)
)
#> Building the URLs...
#> OK
#> Building the URLs...
#> OK
#> Building the URLs...
#> OK
#> Building the URLs...
#> OK

urls_smap <- map(.x = time_ranges, ~odr_get_url(
  collection = "SPL3SMP_E.003",
  variables = c("Soil_Moisture_Retrieval_Data_AM_soil_moisture","Soil_Moisture_Retrieval_Data_AM_retrieval_qual_flag","Soil_Moisture_Retrieval_Data_PM_soil_moisture_pm","Soil_Moisture_Retrieval_Data_PM_retrieval_qual_flag_pm"),
  roi = roi,
  time_range = .x,
  opt_param = opt_param_smap)
  )
#> Building the URLs...
#> OK
#> Building the URLs...
#> OK
#> Building the URLs...
#> OK
#> Building the URLs...
#> OK

str(urls_mod11a1)
#> List of 4
#>  $ :'data.frame':    1 obs. of  4 variables:
#>   ..$ time_start: Date[1:1], format: "2016-01-01"
#>   ..$ name      : chr "MOD11A1.006.2016001_2016031.h17v08"
#>   ..$ url       : chr "https://opendap.cr.usgs.gov/opendap/hyrax/MOD11A1.006/h17v08.ncml.nc4?MODIS_Grid_Daily_1km_LST_eos_cf_projectio"| __truncated__
#>   ..$ destfile  : chr "MOD11A1.006/MOD11A1.006.2016001_2016031.h17v08.nc4"
#>  $ :'data.frame':    1 obs. of  4 variables:
#>   ..$ time_start: Date[1:1], format: "2017-01-01"
#>   ..$ name      : chr "MOD11A1.006.2017001_2017031.h17v08"
#>   ..$ url       : chr "https://opendap.cr.usgs.gov/opendap/hyrax/MOD11A1.006/h17v08.ncml.nc4?MODIS_Grid_Daily_1km_LST_eos_cf_projectio"| __truncated__
#>   ..$ destfile  : chr "MOD11A1.006/MOD11A1.006.2017001_2017031.h17v08.nc4"
#>  $ :'data.frame':    1 obs. of  4 variables:
#>   ..$ time_start: Date[1:1], format: "2018-01-01"
#>   ..$ name      : chr "MOD11A1.006.2018001_2018031.h17v08"
#>   ..$ url       : chr "https://opendap.cr.usgs.gov/opendap/hyrax/MOD11A1.006/h17v08.ncml.nc4?MODIS_Grid_Daily_1km_LST_eos_cf_projectio"| __truncated__
#>   ..$ destfile  : chr "MOD11A1.006/MOD11A1.006.2018001_2018031.h17v08.nc4"
#>  $ :'data.frame':    1 obs. of  4 variables:
#>   ..$ time_start: Date[1:1], format: "2019-01-01"
#>   ..$ name      : chr "MOD11A1.006.2019001_2019031.h17v08"
#>   ..$ url       : chr "https://opendap.cr.usgs.gov/opendap/hyrax/MOD11A1.006/h17v08.ncml.nc4?MODIS_Grid_Daily_1km_LST_eos_cf_projectio"| __truncated__
#>   ..$ destfile  : chr "MOD11A1.006/MOD11A1.006.2019001_2019031.h17v08.nc4"

str(urls_gpm)
#> List of 4
#>  $ :'data.frame':    31 obs. of  4 variables:
#>   ..$ time_start: Date[1:31], format: "2016-01-01" ...
#>   ..$ name      : chr [1:31] "3B-DAY.MS.MRG.3IMERG.20160101-S000000-E235959.V06" "3B-DAY.MS.MRG.3IMERG.20160102-S000000-E235959.V06" "3B-DAY.MS.MRG.3IMERG.20160103-S000000-E235959.V06" "3B-DAY.MS.MRG.3IMERG.20160104-S000000-E235959.V06" ...
#>   ..$ url       : chr [1:31] "https://gpm1.gesdisc.eosdis.nasa.gov/opendap/GPM_L3/GPM_3IMERGDF.06/2016/01/3B-DAY.MS.MRG.3IMERG.20160101-S0000"| __truncated__ "https://gpm1.gesdisc.eosdis.nasa.gov/opendap/GPM_L3/GPM_3IMERGDF.06/2016/01/3B-DAY.MS.MRG.3IMERG.20160102-S0000"| __truncated__ "https://gpm1.gesdisc.eosdis.nasa.gov/opendap/GPM_L3/GPM_3IMERGDF.06/2016/01/3B-DAY.MS.MRG.3IMERG.20160103-S0000"| __truncated__ "https://gpm1.gesdisc.eosdis.nasa.gov/opendap/GPM_L3/GPM_3IMERGDF.06/2016/01/3B-DAY.MS.MRG.3IMERG.20160104-S0000"| __truncated__ ...
#>   ..$ destfile  : chr [1:31] "GPM_3IMERGDF.06/3B-DAY.MS.MRG.3IMERG.20160101-S000000-E235959.V06.nc4" "GPM_3IMERGDF.06/3B-DAY.MS.MRG.3IMERG.20160102-S000000-E235959.V06.nc4" "GPM_3IMERGDF.06/3B-DAY.MS.MRG.3IMERG.20160103-S000000-E235959.V06.nc4" "GPM_3IMERGDF.06/3B-DAY.MS.MRG.3IMERG.20160104-S000000-E235959.V06.nc4" ...
#>  $ :'data.frame':    31 obs. of  4 variables:
#>   ..$ time_start: Date[1:31], format: "2017-01-01" ...
#>   ..$ name      : chr [1:31] "3B-DAY.MS.MRG.3IMERG.20170101-S000000-E235959.V06" "3B-DAY.MS.MRG.3IMERG.20170102-S000000-E235959.V06" "3B-DAY.MS.MRG.3IMERG.20170103-S000000-E235959.V06" "3B-DAY.MS.MRG.3IMERG.20170104-S000000-E235959.V06" ...
#>   ..$ url       : chr [1:31] "https://gpm1.gesdisc.eosdis.nasa.gov/opendap/GPM_L3/GPM_3IMERGDF.06/2017/01/3B-DAY.MS.MRG.3IMERG.20170101-S0000"| __truncated__ "https://gpm1.gesdisc.eosdis.nasa.gov/opendap/GPM_L3/GPM_3IMERGDF.06/2017/01/3B-DAY.MS.MRG.3IMERG.20170102-S0000"| __truncated__ "https://gpm1.gesdisc.eosdis.nasa.gov/opendap/GPM_L3/GPM_3IMERGDF.06/2017/01/3B-DAY.MS.MRG.3IMERG.20170103-S0000"| __truncated__ "https://gpm1.gesdisc.eosdis.nasa.gov/opendap/GPM_L3/GPM_3IMERGDF.06/2017/01/3B-DAY.MS.MRG.3IMERG.20170104-S0000"| __truncated__ ...
#>   ..$ destfile  : chr [1:31] "GPM_3IMERGDF.06/3B-DAY.MS.MRG.3IMERG.20170101-S000000-E235959.V06.nc4" "GPM_3IMERGDF.06/3B-DAY.MS.MRG.3IMERG.20170102-S000000-E235959.V06.nc4" "GPM_3IMERGDF.06/3B-DAY.MS.MRG.3IMERG.20170103-S000000-E235959.V06.nc4" "GPM_3IMERGDF.06/3B-DAY.MS.MRG.3IMERG.20170104-S000000-E235959.V06.nc4" ...
#>  $ :'data.frame':    31 obs. of  4 variables:
#>   ..$ time_start: Date[1:31], format: "2018-01-01" ...
#>   ..$ name      : chr [1:31] "3B-DAY.MS.MRG.3IMERG.20180101-S000000-E235959.V06" "3B-DAY.MS.MRG.3IMERG.20180102-S000000-E235959.V06" "3B-DAY.MS.MRG.3IMERG.20180103-S000000-E235959.V06" "3B-DAY.MS.MRG.3IMERG.20180104-S000000-E235959.V06" ...
#>   ..$ url       : chr [1:31] "https://gpm1.gesdisc.eosdis.nasa.gov/opendap/GPM_L3/GPM_3IMERGDF.06/2018/01/3B-DAY.MS.MRG.3IMERG.20180101-S0000"| __truncated__ "https://gpm1.gesdisc.eosdis.nasa.gov/opendap/GPM_L3/GPM_3IMERGDF.06/2018/01/3B-DAY.MS.MRG.3IMERG.20180102-S0000"| __truncated__ "https://gpm1.gesdisc.eosdis.nasa.gov/opendap/GPM_L3/GPM_3IMERGDF.06/2018/01/3B-DAY.MS.MRG.3IMERG.20180103-S0000"| __truncated__ "https://gpm1.gesdisc.eosdis.nasa.gov/opendap/GPM_L3/GPM_3IMERGDF.06/2018/01/3B-DAY.MS.MRG.3IMERG.20180104-S0000"| __truncated__ ...
#>   ..$ destfile  : chr [1:31] "GPM_3IMERGDF.06/3B-DAY.MS.MRG.3IMERG.20180101-S000000-E235959.V06.nc4" "GPM_3IMERGDF.06/3B-DAY.MS.MRG.3IMERG.20180102-S000000-E235959.V06.nc4" "GPM_3IMERGDF.06/3B-DAY.MS.MRG.3IMERG.20180103-S000000-E235959.V06.nc4" "GPM_3IMERGDF.06/3B-DAY.MS.MRG.3IMERG.20180104-S000000-E235959.V06.nc4" ...
#>  $ :'data.frame':    31 obs. of  4 variables:
#>   ..$ time_start: Date[1:31], format: "2019-01-01" ...
#>   ..$ name      : chr [1:31] "3B-DAY.MS.MRG.3IMERG.20190101-S000000-E235959.V06" "3B-DAY.MS.MRG.3IMERG.20190102-S000000-E235959.V06" "3B-DAY.MS.MRG.3IMERG.20190103-S000000-E235959.V06" "3B-DAY.MS.MRG.3IMERG.20190104-S000000-E235959.V06" ...
#>   ..$ url       : chr [1:31] "https://gpm1.gesdisc.eosdis.nasa.gov/opendap/GPM_L3/GPM_3IMERGDF.06/2019/01/3B-DAY.MS.MRG.3IMERG.20190101-S0000"| __truncated__ "https://gpm1.gesdisc.eosdis.nasa.gov/opendap/GPM_L3/GPM_3IMERGDF.06/2019/01/3B-DAY.MS.MRG.3IMERG.20190102-S0000"| __truncated__ "https://gpm1.gesdisc.eosdis.nasa.gov/opendap/GPM_L3/GPM_3IMERGDF.06/2019/01/3B-DAY.MS.MRG.3IMERG.20190103-S0000"| __truncated__ "https://gpm1.gesdisc.eosdis.nasa.gov/opendap/GPM_L3/GPM_3IMERGDF.06/2019/01/3B-DAY.MS.MRG.3IMERG.20190104-S0000"| __truncated__ ...
#>   ..$ destfile  : chr [1:31] "GPM_3IMERGDF.06/3B-DAY.MS.MRG.3IMERG.20190101-S000000-E235959.V06.nc4" "GPM_3IMERGDF.06/3B-DAY.MS.MRG.3IMERG.20190102-S000000-E235959.V06.nc4" "GPM_3IMERGDF.06/3B-DAY.MS.MRG.3IMERG.20190103-S000000-E235959.V06.nc4" "GPM_3IMERGDF.06/3B-DAY.MS.MRG.3IMERG.20190104-S000000-E235959.V06.nc4" ...

str(urls_smap)
#> List of 4
#>  $ :'data.frame':    31 obs. of  4 variables:
#>   ..$ time_start: Date[1:31], format: "2016-01-01" ...
#>   ..$ name      : chr [1:31] "SMAP_L3_SM_P_E_20160101_R16510_001" "SMAP_L3_SM_P_E_20160102_R16510_001" "SMAP_L3_SM_P_E_20160103_R16510_001" "SMAP_L3_SM_P_E_20160104_R16510_001" ...
#>   ..$ url       : chr [1:31] "https://n5eil02u.ecs.nsidc.org/opendap/SMAP/SPL3SMP_E.003/2016.01.01/SMAP_L3_SM_P_E_20160101_R16510_001.h5.nc4?"| __truncated__ "https://n5eil02u.ecs.nsidc.org/opendap/SMAP/SPL3SMP_E.003/2016.01.02/SMAP_L3_SM_P_E_20160102_R16510_001.h5.nc4?"| __truncated__ "https://n5eil02u.ecs.nsidc.org/opendap/SMAP/SPL3SMP_E.003/2016.01.03/SMAP_L3_SM_P_E_20160103_R16510_001.h5.nc4?"| __truncated__ "https://n5eil02u.ecs.nsidc.org/opendap/SMAP/SPL3SMP_E.003/2016.01.04/SMAP_L3_SM_P_E_20160104_R16510_001.h5.nc4?"| __truncated__ ...
#>   ..$ destfile  : chr [1:31] "SPL3SMP_E.003/SMAP_L3_SM_P_E_20160101_R16510_001.nc4" "SPL3SMP_E.003/SMAP_L3_SM_P_E_20160102_R16510_001.nc4" "SPL3SMP_E.003/SMAP_L3_SM_P_E_20160103_R16510_001.nc4" "SPL3SMP_E.003/SMAP_L3_SM_P_E_20160104_R16510_001.nc4" ...
#>  $ :'data.frame':    31 obs. of  4 variables:
#>   ..$ time_start: Date[1:31], format: "2017-01-01" ...
#>   ..$ name      : chr [1:31] "SMAP_L3_SM_P_E_20170101_R16510_001" "SMAP_L3_SM_P_E_20170102_R16510_001" "SMAP_L3_SM_P_E_20170103_R16510_001" "SMAP_L3_SM_P_E_20170104_R16510_001" ...
#>   ..$ url       : chr [1:31] "https://n5eil02u.ecs.nsidc.org/opendap/SMAP/SPL3SMP_E.003/2017.01.01/SMAP_L3_SM_P_E_20170101_R16510_001.h5.nc4?"| __truncated__ "https://n5eil02u.ecs.nsidc.org/opendap/SMAP/SPL3SMP_E.003/2017.01.02/SMAP_L3_SM_P_E_20170102_R16510_001.h5.nc4?"| __truncated__ "https://n5eil02u.ecs.nsidc.org/opendap/SMAP/SPL3SMP_E.003/2017.01.03/SMAP_L3_SM_P_E_20170103_R16510_001.h5.nc4?"| __truncated__ "https://n5eil02u.ecs.nsidc.org/opendap/SMAP/SPL3SMP_E.003/2017.01.04/SMAP_L3_SM_P_E_20170104_R16510_001.h5.nc4?"| __truncated__ ...
#>   ..$ destfile  : chr [1:31] "SPL3SMP_E.003/SMAP_L3_SM_P_E_20170101_R16510_001.nc4" "SPL3SMP_E.003/SMAP_L3_SM_P_E_20170102_R16510_001.nc4" "SPL3SMP_E.003/SMAP_L3_SM_P_E_20170103_R16510_001.nc4" "SPL3SMP_E.003/SMAP_L3_SM_P_E_20170104_R16510_001.nc4" ...
#>  $ :'data.frame':    31 obs. of  4 variables:
#>   ..$ time_start: Date[1:31], format: "2018-01-01" ...
#>   ..$ name      : chr [1:31] "SMAP_L3_SM_P_E_20180101_R16510_001" "SMAP_L3_SM_P_E_20180102_R16510_001" "SMAP_L3_SM_P_E_20180103_R16510_001" "SMAP_L3_SM_P_E_20180104_R16510_001" ...
#>   ..$ url       : chr [1:31] "https://n5eil02u.ecs.nsidc.org/opendap/SMAP/SPL3SMP_E.003/2018.01.01/SMAP_L3_SM_P_E_20180101_R16510_001.h5.nc4?"| __truncated__ "https://n5eil02u.ecs.nsidc.org/opendap/SMAP/SPL3SMP_E.003/2018.01.02/SMAP_L3_SM_P_E_20180102_R16510_001.h5.nc4?"| __truncated__ "https://n5eil02u.ecs.nsidc.org/opendap/SMAP/SPL3SMP_E.003/2018.01.03/SMAP_L3_SM_P_E_20180103_R16510_001.h5.nc4?"| __truncated__ "https://n5eil02u.ecs.nsidc.org/opendap/SMAP/SPL3SMP_E.003/2018.01.04/SMAP_L3_SM_P_E_20180104_R16510_001.h5.nc4?"| __truncated__ ...
#>   ..$ destfile  : chr [1:31] "SPL3SMP_E.003/SMAP_L3_SM_P_E_20180101_R16510_001.nc4" "SPL3SMP_E.003/SMAP_L3_SM_P_E_20180102_R16510_001.nc4" "SPL3SMP_E.003/SMAP_L3_SM_P_E_20180103_R16510_001.nc4" "SPL3SMP_E.003/SMAP_L3_SM_P_E_20180104_R16510_001.nc4" ...
#>  $ :'data.frame':    31 obs. of  4 variables:
#>   ..$ time_start: Date[1:31], format: "2019-01-01" ...
#>   ..$ name      : chr [1:31] "SMAP_L3_SM_P_E_20190101_R16510_001" "SMAP_L3_SM_P_E_20190102_R16510_001" "SMAP_L3_SM_P_E_20190103_R16510_001" "SMAP_L3_SM_P_E_20190104_R16510_001" ...
#>   ..$ url       : chr [1:31] "https://n5eil02u.ecs.nsidc.org/opendap/SMAP/SPL3SMP_E.003/2019.01.01/SMAP_L3_SM_P_E_20190101_R16510_001.h5.nc4?"| __truncated__ "https://n5eil02u.ecs.nsidc.org/opendap/SMAP/SPL3SMP_E.003/2019.01.02/SMAP_L3_SM_P_E_20190102_R16510_001.h5.nc4?"| __truncated__ "https://n5eil02u.ecs.nsidc.org/opendap/SMAP/SPL3SMP_E.003/2019.01.03/SMAP_L3_SM_P_E_20190103_R16510_001.h5.nc4?"| __truncated__ "https://n5eil02u.ecs.nsidc.org/opendap/SMAP/SPL3SMP_E.003/2019.01.04/SMAP_L3_SM_P_E_20190104_R16510_001.h5.nc4?"| __truncated__ ...
#>   ..$ destfile  : chr [1:31] "SPL3SMP_E.003/SMAP_L3_SM_P_E_20190101_R16510_001.nc4" "SPL3SMP_E.003/SMAP_L3_SM_P_E_20190102_R16510_001.nc4" "SPL3SMP_E.003/SMAP_L3_SM_P_E_20190103_R16510_001.nc4" "SPL3SMP_E.003/SMAP_L3_SM_P_E_20190104_R16510_001.nc4" ...

Import the data in R

stars or ncdf4 object are best adapted for these kind of spatiotemporal data. However, in this example we will show how to import them as lists of RasterLayer objects : one list for each time range.

First, we write the functions to import the data as RasterLayer objects (check out Important note regarding the further import of the data in R in the vignette("opendapr1") for additional information)

## Function to import MODIS or VIIRS data
.import_modis <- function(destfiles,variable){
  
  rasts <- destfiles %>%
    raster::brick(varname = variable, crs = "+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs")
  
  return(rasts)
}

## Function to import GPM data
.import_gpm <- function(destfiles,variable){
  
  rasts <- destfiles %>%
    purrr::map(~raster(., varname = variable,crs = "+init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 ")) %>%
    raster::brick() %>%
    raster::t() %>%
    raster::flip("y") %>%
    raster::flip("x")

  return(rasts)
}

## Function to import SMAP data
.import_smap <- function(destfiles,variable,smap_sp_bound){
  
 rasts <- destfiles %>%
   purrr::map(~ncdf4::nc_open(.)) %>%
   purrr::map(~ncdf4::ncvar_get(., variable)) %>%
   purrr::map(~raster(t(.), ymn=smap_sp_bound[1], ymx=smap_sp_bound[2], xmn=smap_sp_bound[3], xmx=smap_sp_bound[4], crs="+proj=cea +lon_0=0 +lat_ts=30 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0")) %>%  # EPSG : 6933
   raster::brick()

  return(rasts)
}

We now use these functions to import the data (here, only 1 band is selected for each data collection). Output is a list of 4 elements (1 by time frame provided in time_ranges ). Each element is a RasterBrick containing 1 layer for each day (hence, here, 30 days).

# MODIS
modis_ts <- urls_mod11a1 %>%
  purrr::map(~.import_modis(.$destfile,"LST_Day_1km"))
## or even better : as stars objects (will import all the bands, i.e. no need to select one band only)
# modis_ts <- urls_mod11a1 %>%
#   purrr::map(~stars::read_stars(.$destfile)) %>%
#   purrr::map(~st_set_crs(.,"+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs"))

# GPM
gpm_ts <- urls_gpm %>%
  purrr::map(~.import_gpm(.$destfile,"precipitationCal"))

# SMAP
smap_sp_bound <- opendapr::odr_get_opt_param(roi = roi, collection = "SPL3SMP_E.003")$roiSpatialBound$`1`
smap_ts <- urls_smap %>%
  purrr::map(~.import_smap(.$destfile,"Soil_Moisture_Retrieval_Data_AM_soil_moisture",smap_sp_bound))

print(modis_ts)
#> [[1]]
#> class       : RasterBrick 
#> dimensions  : 86, 49, 4214, 31  (nrow, ncol, ncell, nlayers)
#> resolution  : 926.6254, 926.6254  (x, y)
#> extent      : -637981.6, -592577, 981759.6, 1061449  (xmin, xmax, ymin, ymax)
#> coord. ref. : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs 
#> data source : /home/ptaconet/opendapr/vignettes/MOD11A1.006/MOD11A1.006.2016001_2016031.h17v08.nc4 
#> names       : X2016.01.01, X2016.01.02, X2016.01.03, X2016.01.04, X2016.01.05, X2016.01.06, X2016.01.07, X2016.01.08, X2016.01.09, X2016.01.10, X2016.01.11, X2016.01.12, X2016.01.13, X2016.01.14, X2016.01.15, ... 
#> Date        : 2016-01-01, 2016-01-31 (min, max)
#> varname     : LST_Day_1km 
#> 
#> 
#> [[2]]
#> class       : RasterBrick 
#> dimensions  : 86, 49, 4214, 31  (nrow, ncol, ncell, nlayers)
#> resolution  : 926.6254, 926.6254  (x, y)
#> extent      : -637981.6, -592577, 981759.6, 1061449  (xmin, xmax, ymin, ymax)
#> coord. ref. : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs 
#> data source : /home/ptaconet/opendapr/vignettes/MOD11A1.006/MOD11A1.006.2017001_2017031.h17v08.nc4 
#> names       : X2017.01.01, X2017.01.02, X2017.01.03, X2017.01.04, X2017.01.05, X2017.01.06, X2017.01.07, X2017.01.08, X2017.01.09, X2017.01.10, X2017.01.11, X2017.01.12, X2017.01.13, X2017.01.14, X2017.01.15, ... 
#> Date        : 2017-01-01, 2017-01-31 (min, max)
#> varname     : LST_Day_1km 
#> 
#> 
#> [[3]]
#> class       : RasterBrick 
#> dimensions  : 86, 49, 4214, 31  (nrow, ncol, ncell, nlayers)
#> resolution  : 926.6254, 926.6254  (x, y)
#> extent      : -637981.6, -592577, 981759.6, 1061449  (xmin, xmax, ymin, ymax)
#> coord. ref. : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs 
#> data source : /home/ptaconet/opendapr/vignettes/MOD11A1.006/MOD11A1.006.2018001_2018031.h17v08.nc4 
#> names       : X2018.01.01, X2018.01.02, X2018.01.03, X2018.01.04, X2018.01.05, X2018.01.06, X2018.01.07, X2018.01.08, X2018.01.09, X2018.01.10, X2018.01.11, X2018.01.12, X2018.01.13, X2018.01.14, X2018.01.15, ... 
#> Date        : 2018-01-01, 2018-01-31 (min, max)
#> varname     : LST_Day_1km 
#> 
#> 
#> [[4]]
#> class       : RasterBrick 
#> dimensions  : 86, 49, 4214, 31  (nrow, ncol, ncell, nlayers)
#> resolution  : 926.6254, 926.6254  (x, y)
#> extent      : -637981.6, -592577, 981759.6, 1061449  (xmin, xmax, ymin, ymax)
#> coord. ref. : +proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs 
#> data source : /home/ptaconet/opendapr/vignettes/MOD11A1.006/MOD11A1.006.2019001_2019031.h17v08.nc4 
#> names       : X2019.01.01, X2019.01.02, X2019.01.03, X2019.01.04, X2019.01.05, X2019.01.06, X2019.01.07, X2019.01.08, X2019.01.09, X2019.01.10, X2019.01.11, X2019.01.12, X2019.01.13, X2019.01.14, X2019.01.15, ... 
#> Date        : 2019-01-01, 2019-01-31 (min, max)
#> varname     : LST_Day_1km

print(gpm_ts)
#> [[1]]
#> class       : RasterBrick 
#> dimensions  : 8, 5, 40, 31  (nrow, ncol, ncell, nlayers)
#> resolution  : 0.1000023, 0.09999956  (x, y)
#> extent      : -5.800004, -5.299993, 8.900002, 9.699998  (xmin, xmax, ymin, ymax)
#> coord. ref. : +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
#> data source : in memory
#> names       :     layer.1,     layer.2,     layer.3,     layer.4,     layer.5,     layer.6,     layer.7,     layer.8,     layer.9,    layer.10,    layer.11,    layer.12,    layer.13,    layer.14,    layer.15, ... 
#> min values  : 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.020688403, 0.114505127, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, ... 
#> max values  : 0.023946110, 0.100000001, 0.000000000, 0.104326740, 0.802038670, 2.774286747, 0.485472620, 0.189618543, 0.014000000, 0.088715874, 0.000000000, 0.004668009, 0.000000000, 0.000000000, 0.012473024, ... 
#> 
#> 
#> [[2]]
#> class       : RasterBrick 
#> dimensions  : 8, 5, 40, 31  (nrow, ncol, ncell, nlayers)
#> resolution  : 0.1000023, 0.09999956  (x, y)
#> extent      : -5.800004, -5.299993, 8.900002, 9.699998  (xmin, xmax, ymin, ymax)
#> coord. ref. : +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
#> data source : in memory
#> names       :     layer.1,     layer.2,     layer.3,     layer.4,     layer.5,     layer.6,     layer.7,     layer.8,     layer.9,    layer.10,    layer.11,    layer.12,    layer.13,    layer.14,    layer.15, ... 
#> min values  : 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.015777921, 0.000000000, 0.021967307, 0.002506131, 0.000000000, 0.000000000, ... 
#> max values  :  0.00000000,  1.00454104,  0.01239155,  0.00000000,  0.00000000,  0.00000000,  0.00000000,  0.02110096,  0.34920487,  0.42241478,  2.99069405,  5.54364347,  0.19833815,  0.21644105,  1.17732072, ... 
#> 
#> 
#> [[3]]
#> class       : RasterBrick 
#> dimensions  : 8, 5, 40, 31  (nrow, ncol, ncell, nlayers)
#> resolution  : 0.1000023, 0.09999956  (x, y)
#> extent      : -5.800004, -5.299993, 8.900002, 9.699998  (xmin, xmax, ymin, ymax)
#> coord. ref. : +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
#> data source : in memory
#> names       :     layer.1,     layer.2,     layer.3,     layer.4,     layer.5,     layer.6,     layer.7,     layer.8,     layer.9,    layer.10,    layer.11,    layer.12,    layer.13,    layer.14,    layer.15, ... 
#> min values  :           0,           0,           0,           0,           0,           0,           0,           0,           0,           0,           0,           0,           0,           0,           0, ... 
#> max values  : 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, ... 
#> 
#> 
#> [[4]]
#> class       : RasterBrick 
#> dimensions  : 8, 5, 40, 31  (nrow, ncol, ncell, nlayers)
#> resolution  : 0.1000023, 0.09999956  (x, y)
#> extent      : -5.800004, -5.299993, 8.900002, 9.699998  (xmin, xmax, ymin, ymax)
#> coord. ref. : +init=epsg:4326 +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
#> data source : in memory
#> names       :     layer.1,     layer.2,     layer.3,     layer.4,     layer.5,     layer.6,     layer.7,     layer.8,     layer.9,    layer.10,    layer.11,    layer.12,    layer.13,    layer.14,    layer.15, ... 
#> min values  : 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, 0.000000000, ... 
#> max values  :  0.19960466,  0.10788161,  0.00000000,  0.00000000,  0.73508704,  2.86901855,  0.48457938,  3.71840620,  1.08807325,  3.39184451,  0.12185285,  0.86521268,  2.74673152,  0.06515764,  0.61251777, ...

print(smap_ts)
#> [[1]]
#> class       : RasterBrick 
#> dimensions  : 11, 6, 66, 31  (nrow, ncol, ncell, nlayers)
#> resolution  : 7506.713, 8189.135  (x, y)
#> extent      : -563003.5, -517963.2, 1121503, 1211583  (xmin, xmax, ymin, ymax)
#> coord. ref. : +proj=cea +lon_0=0 +lat_ts=30 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 
#> data source : in memory
#> names       :    layer.1,    layer.2,    layer.3,    layer.4,    layer.5,    layer.6,    layer.7,    layer.8,    layer.9,   layer.10,   layer.11,   layer.12,   layer.13,   layer.14,   layer.15, ... 
#> min values  :         NA,         NA, 0.08794813,         NA, 0.09045634, 0.09929898,         NA, 0.10024372,         NA,         NA, 0.09286496,         NA, 0.09519173, 0.10333401,         NA, ... 
#> max values  :         NA,         NA,  0.1536734,         NA,  0.1585532,  0.1305509,         NA,  0.1419851,         NA,         NA,  0.1425952,         NA,  0.1435617,  0.1323697,         NA, ... 
#> 
#> 
#> [[2]]
#> class       : RasterBrick 
#> dimensions  : 11, 6, 66, 31  (nrow, ncol, ncell, nlayers)
#> resolution  : 7506.713, 8189.135  (x, y)
#> extent      : -563003.5, -517963.2, 1121503, 1211583  (xmin, xmax, ymin, ymax)
#> coord. ref. : +proj=cea +lon_0=0 +lat_ts=30 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 
#> data source : in memory
#> names       :    layer.1,    layer.2,    layer.3,    layer.4,    layer.5,    layer.6,    layer.7,    layer.8,    layer.9,   layer.10,   layer.11,   layer.12,   layer.13,   layer.14,   layer.15, ... 
#> min values  :         NA, 0.09996461,         NA,         NA, 0.09471568,         NA, 0.05590146,         NA,         NA, 0.09872495,         NA,         NA, 0.09351711,         NA, 0.06066480, ... 
#> max values  :         NA,  0.1452434,         NA,         NA,  0.1560785,         NA,  0.1505869,         NA,         NA,  0.1704942,         NA,         NA,  0.1503100,         NA,  0.1584005, ... 
#> 
#> 
#> [[3]]
#> class       : RasterBrick 
#> dimensions  : 11, 6, 66, 31  (nrow, ncol, ncell, nlayers)
#> resolution  : 7506.713, 8189.135  (x, y)
#> extent      : -563003.5, -517963.2, 1121503, 1211583  (xmin, xmax, ymin, ymax)
#> coord. ref. : +proj=cea +lon_0=0 +lat_ts=30 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 
#> data source : in memory
#> names       :    layer.1,    layer.2,    layer.3,    layer.4,    layer.5,    layer.6,    layer.7,    layer.8,    layer.9,   layer.10,   layer.11,   layer.12,   layer.13,   layer.14,   layer.15, ... 
#> min values  :         NA, 0.10006880,         NA,         NA, 0.09495438,         NA,         NA, 0.09292481,         NA, 0.10110421,         NA,         NA, 0.08756919,         NA,         NA, ... 
#> max values  :         NA,  0.1684048,         NA,         NA,  0.1438731,         NA,         NA,  0.1462391,         NA,  0.1599983,         NA,         NA,  0.1463772,         NA,         NA, ... 
#> 
#> 
#> [[4]]
#> class       : RasterBrick 
#> dimensions  : 11, 6, 66, 31  (nrow, ncol, ncell, nlayers)
#> resolution  : 7506.713, 8189.135  (x, y)
#> extent      : -563003.5, -517963.2, 1121503, 1211583  (xmin, xmax, ymin, ymax)
#> coord. ref. : +proj=cea +lon_0=0 +lat_ts=30 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0 
#> data source : in memory
#> names       :    layer.1,    layer.2,    layer.3,    layer.4,    layer.5,    layer.6,    layer.7,    layer.8,    layer.9,   layer.10,   layer.11,   layer.12,   layer.13,   layer.14,   layer.15, ... 
#> min values  :         NA,         NA, 0.09937777,         NA, 0.09308220,         NA,         NA, 0.09426465,         NA,         NA, 0.10470568,         NA, 0.09455165,         NA,         NA, ... 
#> max values  :         NA,         NA,  0.1483180,         NA,  0.1420667,         NA,         NA,  0.1392520,         NA,         NA,  0.1505259,         NA,  0.1515075,         NA,         NA, ...