Reading PROBA-V data from R

This notebook illustrates how to find locations of PROBA-V data, and reads them using the preinstalled R raster package. No further processing is carried out. We use the 'reticulate' R library to access a Python library that supports finding locations of PROBA-V products on the MEP. Reusing this Python library ensures that R users can also benefit from everything that is implemented for Python users.

Load the reticulate library (R-Python bridge) and point it to the Python version that comes preconfigured with all modules.

In [1]:
library(reticulate)

Use reticulate calls to load our 'catalogclient' library, written in Python. More information about the catalog service for PROBA-V product lookup can be found here: https://proba-v-mep.esa.int/documentation/manuals/product-catalog-api Using the catalog API avoids having to write our own file lookup code.

In [2]:
catalogclient <- import("catalogclient")
cat=catalogclient$catalog$Catalog()
cat$get_producttypes()
  1. 'BioPar_ALB_BHV_V1_Tiles'
  2. 'BioPar_ALB_DHV_V1_Tiles'
  3. 'BioPar_ALBH_V1_Global'
  4. 'BioPar_BA_V1_Tiles'
  5. 'BioPar_DMP_Tiles'
  6. 'BioPar_DMP300_V1_Global'
  7. 'BioPar_FAPAR_V1_Tiles'
  8. 'BioPar_FAPAR_V1_Global'
  9. 'BioPar_FAPAR_V2_Global'
  10. 'BioPar_FCOVER_V1_Tiles'
  11. 'BioPar_FCOVER_V1_Global'
  12. 'BioPar_FCOVER_V2_Global'
  13. 'BioPar_LAI_V1_Tiles'
  14. 'BioPar_LAI_V1_Global'
  15. 'BioPar_LAI_V2_Global'
  16. 'BioPar_NDVI300_V1_Global'
  17. 'BioPar_NDVI300_V1_Global_GTIFF'
  18. 'BioPar_BA300_V1_Global'
  19. 'BioPar_FCOVER300_V1_Global'
  20. 'BioPar_FAPAR300_V1_Global'
  21. 'BioPar_LAI300_V1_Global'
  22. 'BioPar_NDVI_V1_Tiles'
  23. 'BioPar_NDVI_V2_Tiles'
  24. 'BioPar_NDVI_V2_Global'
  25. 'BioPar_SWI'
  26. 'BioPar_SWI10_V3_Global'
  27. 'BioPar_TOCR_Tiles'
  28. 'BioPar_VCI_Tiles'
  29. 'BioPar_VPI_Tiles'
  30. 'BioPar_WB_V1_Tiles'
  31. 'BioPar_WB_V2_Tiles'
  32. 'BioPar_WB_V2_Global'
  33. 'BioPar_WB300_V1_Global'
  34. 'PROBAV_L3_S1_TOC_1KM'
  35. 'PROBAV_L3_S1_TOC_333M'
  36. 'PROBAV_L3_S10_TOC_333M'
  37. 'PROBAV_L3_S5_TOC_100M'
  38. 'PROBAV_L3_S1_TOC_100M'
  39. 'PROBAV_L3_S10_TOC_1KM'
  40. 'PROBAV_L3_S1_TOA_1KM'
  41. 'PROBAV_L3_S1_TOA_333M'
  42. 'PROBAV_L3_S5_TOA_100M'
  43. 'PROBAV_L3_S1_TOA_100M'
  44. 'PROBAV_L1C'
  45. 'PROBAV_L2A_1KM'
  46. 'PROBAV_L2A_333M'
  47. 'PROBAV_L2A_100M'
  48. 'CGS_S2_FAPAR'
  49. 'CGS_S2_FAPAR_10M'
  50. 'CGS_S2_FAPAR_20M'
  51. 'CGS_S2_NDVI'
  52. 'CGS_S2_NDVI_10M'
  53. 'CGS_S2_LAI'
  54. 'CGS_S2_LAI_10M'
  55. 'CGS_S2_LAI_20M'
  56. 'CGS_S2_FCOVER'
  57. 'CGS_S2_FCOVER_10M'
  58. 'CGS_S2_FCOVER_20M'
  59. 'CGS_S2_RADIOMETRY'
  60. 'CGS_S2_RADIOMETRY_10M'
  61. 'CGS_S2_RADIOMETRY_20M'
  62. 'CGS_S2_RADIOMETRY_60M'
  63. 'CGS_S1_GRD_SIGMA0_L1'
  64. 'NEXTGEOSS_SENTINEL2_FAPAR'
  65. 'NEXTGEOSS_SENTINEL2_NDVI'
  66. 'NEXTGEOSS_SENTINEL2_LAI'
  67. 'NEXTGEOSS_SENTINEL2_FCOVER'
  68. 'NEXTGEOSS_SENTINEL2_RADIOMETRY'
  69. 'FSTEP_SENTINEL2_FAPAR'
  70. 'FSTEP_SENTINEL2_NDVI'
  71. 'FSTEP_SENTINEL2_LAI'
  72. 'FSTEP_SENTINEL2_FCOVER'
  73. 'FSTEP_SENTINEL2_RADIOMETRY'
  74. 'SPOTVEGETATION_L3_S1'
  75. 'SPOTVEGETATION_L3_S10'

Use the get_products method to get some information about products in a particular date range and bounding box.

In [3]:
date = "2017-04-20"
products = cat$get_products('PROBAV_L3_S1_TOC_333M', 
                            fileformat='GEOTIFF', 
                            startdate=date, 
                            enddate=date, 
                            min_lon=0, max_lon=10, min_lat=36, max_lat=53)

str(products[[1]]$files)
str(products[[1]]$producttype)
List of 5
 $ :file:/data/MTDA/TIFFDERIVED/PROBAV_L3_S1_TOC_333M/2017/20170420/PROBAV_S1_TOC_20170420_333M_V101/PROBAV_S1_TOC_X18Y02_20170420_333M_V101_TIME.tif
 $ :file:/data/MTDA/TIFFDERIVED/PROBAV_L3_S1_TOC_333M/2017/20170420/PROBAV_S1_TOC_20170420_333M_V101/PROBAV_S1_TOC_X18Y02_20170420_333M_V101_RADIOMETRY.tif
 $ :file:/data/MTDA/TIFFDERIVED/PROBAV_L3_S1_TOC_333M/2017/20170420/PROBAV_S1_TOC_20170420_333M_V101/PROBAV_S1_TOC_X18Y02_20170420_333M_V101_SM.tif
 $ :file:/data/MTDA/TIFFDERIVED/PROBAV_L3_S1_TOC_333M/2017/20170420/PROBAV_S1_TOC_20170420_333M_V101/PROBAV_S1_TOC_X18Y02_20170420_333M_V101_GEOMETRY.tif
 $ :file:/data/MTDA/TIFFDERIVED/PROBAV_L3_S1_TOC_333M/2017/20170420/PROBAV_S1_TOC_20170420_333M_V101/PROBAV_S1_TOC_X18Y02_20170420_333M_V101_NDVI.tif
 chr "PROBAV_L3_S1_TOC_333M"

The API call returns metadata as objects, containing file locations for all bands, we can use some plain R code to transform this list in a simple list of NDVI file locations.

In [4]:
ndvi_files = lapply(products,function(p) p$file("NDVI"))
str(ndvi_files)
List of 2
 $ : chr "file:/data/MTDA/TIFFDERIVED/PROBAV_L3_S1_TOC_333M/2017/20170420/PROBAV_S1_TOC_20170420_333M_V101/PROBAV_S1_TOC_"| __truncated__
 $ : chr "file:/data/MTDA/TIFFDERIVED/PROBAV_L3_S1_TOC_333M/2017/20170420/PROBAV_S1_TOC_20170420_333M_V101/PROBAV_S1_TOC_"| __truncated__

Now that we found some files to process, we can do things. In this case, we will simply plot it using standard functionality from the 'raster' library, which is preinstalled.

In [5]:
library(raster)
str(substring(ndvi_files[1],6))

r <- raster(substring(ndvi_files[1],6))
plot(r, main='PROBA-V Tile X18 Y02')
Loading required package: sp
 chr "/data/MTDA/TIFFDERIVED/PROBAV_L3_S1_TOC_333M/2017/20170420/PROBAV_S1_TOC_20170420_333M_V101/PROBAV_S1_TOC_X18Y0"| __truncated__