S5P_process: Sentinel-5P L2 Processing Tool

View source: R/S5P_process.R

S5P_processR Documentation

Sentinel-5P L2 Processing Tool

Description

This function automatically converts the Sentinel-5P L2 NC-data files into TIFF files. The user can define a additional aoi, the preferred resolution as well as the resampling method.

Usage

S5P_process(input, product, my_res, my_aoi, extent_only, ref_raster,
  interpol_method, apply_scale_factor)

Arguments

input

A vector or single character string containing the path(s) to the NetCDF file(s).

product

(optional) Define a number for the product that should be transformed into a raster file. If not defined, the user will be prompted to choose from a list when executing the function.

my_res

(optional) Define geometric resolution in m for the final raster file. The actual resolution will likely differ slightly from the users preset, since the extent of the NetCDF data or provided aoi/reference data will be used and turned into a raster file. The dimensions of the extent will be devided by the resolution and the resulting decimal number will be rounded to an integer to provide the number of rows and columns for the resulting raster file -> Default is 20000m.

my_aoi

(optional) Shapefile which will be used to crop the data.

extent_only

(optional) If TRUE it will only use the extent of the aoi or reference raster to crop the data, if FALSE (default) the NetCDF data will be masked to the aoi/ref_raster.

ref_raster

(optional) Raster file to which the S5P data will be cropped, projected, including resolution.

interpol_method

(optional) Either 'ngb' (nearest neighbor) or 'bilinear' (bilinear interpolation; the default value).

apply_scale_factor

(optional) If TRUE it will convert the pixel values to molecules per cm2 if a multiplication factor is available for the defined product. If there is no multiplication factor available or set to FALSE (default) the original unit of the product will be used.

Value

A Tiff file.

References

This program was written at Remote Sensing Solutions RSS GmbH, Dingolfinger Str. 9, 81673 Munich, Germany https://rssgmbh.de/.

Examples

# Load required packages
library(ncdf4)
library(ggplot2)
library(dismo)
library(maptools)
library(raster)
library(geosphere)
library(rgdal)
library(rgeos)
library(sp)
library(S5Processor)


# Load sample NetCDF files
x1 <- system.file(package = "S5Processor", "extdata", "S5P_NRTI_L2__NO2_1.nc")
x2 <- system.file(package = "S5Processor", "extdata", "S5P_NRTI_L2__NO2_2.nc")

# Load sample shapefile including the borders of vietnam
vnm_shp <- raster::shapefile(system.file(package = "S5Processor",
                             "extdata", "vietnam_borders.shp"))

# Create vector from both NetCDF files.
my_files <- c(x1,x2)

# Most basic case: provide path to single NetCDF file.
# The user will be promted to choose from a list of product names.
S5P_1 <- S5P_process(input = my_files[1])

# Execute function on several files at once; additionally provide product number.
S5P_2 <- S5P_process(input = my_files, product = 39)

# As above but this time also mask data to aoi and define resolution.
S5P_3 <- S5P_process(input = my_files, my_res = 10000,
                     product = 39, my_aoi = vnm_shp,
                     extent_only = FALSE)

# This time also apply scale factor to convert units to molecules per cm2.
S5P_4 <- S5P_process(input = my_files, my_res = 10000,
                     product = 39, my_aoi = vnm_shp,
                     extent_only = FALSE,
                     apply_scale_factor = T)


MBalthasar/S5Processor documentation built on Aug. 15, 2022, 5:20 a.m.