Skip to contents

This function is used to query a specific raster product in the FAO Gismanager. Because data sets within the database vary greatly between the different collection this function uses an easily abstractable pattern for the query. Users can simply query a specific product from a collection for a given spatio-temporal extent and download all available dimensions. In case user's only want to download specific dimensions of a product these can be speicifed as a list object with the dimension argument. Note that temporal dimensions do not need to be specified since they are derived automatically. The function requires a valid API key for the FAO Gismanager. User's can additionally specify the processing to be applied to the resulting raster file such as if the valid pixel range should be cut to the borders of the aoi object, tiling and overview creation of the raster and if the raster shall be compressed. Note that any of these process will increase processing time on the server-side.

Usage

wapor_queryRaster(
  collection = NULL,
  product = NULL,
  dimensions = list(),
  aoi = NULL,
  begin = NULL,
  end = NULL,
  APIkey = NULL,
  outdir = ".",
  cutline = FALSE,
  tiled = FALSE,
  compressed = FALSE,
  overviews = FALSE,
  sleep_time = 5,
  stubbornness = 50
)

Arguments

collection

A length one charachter vector indication the collection where the queried product is found.

product

A length one character vector indicating the desired product to download.

dimensions

A list object specifying the dimensions of the product expect of the time and measurment dimensions. Any other dimensions needs to be specified in the form of dimensions = list(KEY = "value"). In cases of products with only the temporal and measurement dimension an empty list should be handed to the function. This is also the Default.

aoi

An sf object which bounding box is used to clip the raster extent. This is only relevant for regional or global datasets when clipping is desired. Simply omit this option when you want to download a complete dataset (e.g. a global dataset or a very local dataset such as WAPOR L3 data). The function will issue a warning in these cases that the extent was set to global/regional.

begin

A length one character in the form of "YYYY-MM-DD" or an Date object in the same format. This time parameter is inclusive meaning that all timestemps equal or higher than begin will be included.

end

A length one character in the form of "YYYY-MM-DD" or an Date object in the same format. This parameter is exclusive meaning that all timestemps lower that end will be included.

APIkey

A length one character containing your API key. Can be obtained in the profile section at https://wapor.apps.fao.org.

outdir

A length one character vector with an existing directory. Any output files will be written here.

cutline

A logical indicating whether the resulting raster should be cut to the bounding box of the aoi object. Only relevant when aoi is specified.

tiled

Logical whether the resulting raster file should be tiled.

compressed

Logical to indicate if the resulting raster should be compressed using LZW.

overviews

Logical to indicate if overviews for the resulting raster should be created.

sleep_time

A numeric value indicating the length of time R sleeps when checking for the availability of the result in seconds. Depending on the size of the queried raster (e.g. global extent at high spatial resolution) it might be a good idea to increase the sleep time. Defaults to 10 seconds.

stubbornness

Number of maximum iterations the function will query the server for the result of one raster query. The length of one iteration is derived from the sleep_time argument. If the maximum number of iterations has been reached and the server did not finish the calculation the function will return an error.

Value

Nothing. The function downloads raster files from the FAO WaPOR API to a specific output directory.