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.
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.
catalogclient <- import("catalogclient")
cat=catalogclient$catalog$Catalog()
cat$get_producttypes()
Use the get_products method to get some information about products in a particular date range and bounding box.
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.
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.
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__