<jupyter_start><jupyter_text>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.<jupyter_code>library(reticulate)<jupyter_output><empty_output><jupyter_text>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-apiUsing the catalog API avoids having to write our own file lookup code.<jupyter_code>catalogclient <- import("catalogclient")
cat=catalogclient$catalog$Catalog()
cat$get_producttypes()<jupyter_output><empty_output><jupyter_text>Use the get_products method to get some information about products in a particular date range and bounding box.<jupyter_code>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)<jupyter_output>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"<jupyter_text>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.<jupyter_code>ndvi_files = lapply(products,function(p) p$file("NDVI"))
str(ndvi_files)<jupyter_output>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__<jupyter_text>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.<jupyter_code>library(raster)
str(substring(ndvi_files[1],6))

r <- raster(substring(ndvi_files[1],6))
plot(r, main='PROBA-V Tile X18 Y02')<jupyter_output>Loading required package: sp
{'fraction_non_alphanumeric': 0.07947415596056169, 'fraction_numerical': 0.10696145802210935, 'mean_word_length': 6.00418410041841, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 18, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '333994', 'license': 'Apache-2.0', 'n_tokens_mistral': 1498, 'n_tokens_neox': 1260, 'n_words': 245, 'path': 'tools/r/Reading PROBA-V using R.ipynb', 'repo_name': 'VITObelgium/notebook-samples', 'size': '3347'}