Package 'cropDemand'

Title: Spatial Crop Water Demand for Brazil
Description: Estimation of crop water demand can be processed via this package. As example, the data from 'TerraClimate' dataset (<https://www.climatologylab.org/terraclimate.html>) calibrated with automatic weather stations of National Meteorological Institute of Brazil is available in a coarse spatial resolution to do the crop water demand. However, the user have also the option to download the variables directly from 'TerraClimate' repository with the download.terraclimate function and access the original 'TerraClimate' products. If the user believes that is necessary calibrate the variables, there is another function to do it. Lastly, the estimation of the crop water demand present in this package can be run for all the Brazilian territory with 'TerraClimate' dataset.
Authors: Roberto Filgueiras [aut, cre] , Luan P. Venancio [aut] , Catariny C. Aleman [aut] , Fernando F. da Cunha [aut]
Maintainer: Roberto Filgueiras <[email protected]>
License: CC BY 4.0
Version: 1.0.3
Built: 2024-11-02 04:27:49 UTC
Source: https://github.com/filgueirasr/cropdemand

Help Index


Calculates the aridity index

Description

The aridity index (AI) is a numerical indicator used to quantify the degree of dryness of a climate at a given location. It is calculated as the ratio of annual precipitation to potential evapotranspiration.

Usage

ai_index_calculation(annual_img_ppt, annual_img_etp)

Arguments

annual_img_ppt

rast image with the annual sum of the precipitation

annual_img_etp

rast image of annual sum of the potential evapotranspiration

Value

Returns a SpatRaster with the calculation.

Examples

## Not run: 

 ai_index_img <- ai_index_calculation(annual_img_ppt, annual_img_etp);

## End(Not run)

Download of reference evapotranspiration (eto) and rainfall (ppt) from 'TerraClimate'

Description

This function will download the eto and ppt and will load a SpatRaster according to the the region of interest (Region and sub_region).

Usage

download_terraclimate(dir_out, variable, years, region, sub_region)

Arguments

dir_out

Directory where you want to save the raster images that you are goind to download.

variable

Variable to download. This function will download the eto or ppt (SpatRaster).

years

The period in years that the function should download images.

region

Use the "brazil" shapefile to extract the SpatRaster (variable) for one state (Brazilian state), or use the "biomes_brazil" to extract the SpatRaster (variable) for one biome of Brazil.

sub_region

You have two options in this section, if you choice the brazil (in region parameter) you need to choice the Brazilian states, but if you choice the biomes_brazil (in region parameter) you must choice one of Brazilian biomes.

Value

Download for the region of interest the ppt (Rainfall) or eto (reference evapotranspiration) SpatRaster

References

The images used in this package can be found in the paper: Abatzoglou, J.T., S.Z. Dobrowski, S.A. Parks, K.C. Hegewisch, 2018, Terraclimate, a high-resolution global dataset of monthly climate and climatic water balance from 1958-2015, Scientific Data.

Examples

## Not run: 

### Downloading eto based on Brazil states.
see_brazil_states()

img<-download_terraclimate(dir_out,
                          variable = "eto",
                          years = c(2018:2019),
                          region = "brazil",
                          sub_region = 13)

### Downloading the ppt based on Brazil biomes.
see_brazil_biomes()

img<-download_terraclimate(dir_out,
                          variable = "ppt",
                          years = c(2018:2019),
                          region = "biomes_brazil",
                          sub_region = 6)

## End(Not run)

Calibration of reference evapotranspiration (eto) of 'TerraClimate'

Description

This function will calibrate the reference evapotranspiration (eto) from TerraClimate dataset based in the relationship with observed weather stations data.

Usage

eto_calibration(slope, intercept, eto_stack)

Arguments

slope

the slope of the linear regression (numeric).

intercept

the intercept of the linear regression (numeric).

eto_stack

stack of eto.

Value

Returns a SpatRaster of eto calibrated.

Examples

## Not run: 
eto_cal<- eto_calibration(slope = 0.930073,
                           intercept = 22.399986, eto_stack = etp);

## End(Not run)

Load image data to do crop water demand

Description

This fuction will load the evapotranspiration and rainfall data for the region of interest (ROI).

Usage

loadROI(variable, region, sub_region)

Arguments

variable

Stack of evapotranspiration or rainfall (SpatRaster).

region

Use the "brazil" shp file to extract the SpatRaster (variable) for one state (Brazilian state), or use the "biomes_brazil" to extract the SpatRaster (variable) for one biome of Brazil.

sub_region

You have two options in this section, if you choice the brazil (in region parameter) you need to choice the Brazilian states, but if you choice the biomes-brazil (in region parameter) you must choice one of Brazilian biomes.

Value

Load the reference evapotranspiration (eto) or rainfall (ppt) SpatRaster

References

The images used in this package can be found in the paper: Abatzoglou, J.T., S.Z. Dobrowski, S.A. Parks, K.C. Hegewisch, 2018, Terraclimate, a high-resolution global dataset of monthly climate and climatic water balance from 1958-2015, Scientific Data.

Examples

## Not run: 
#For Brazilian states

see_brazil_states()

image_etp<-loadROI(variable = "eto", region = "brazil",
                    sub_region = 13) # sub_regions 1:27

image_rainfall<-loadROI(variable = "ppt",
                        region = "brazil", sub_region = 13)

#For Brazilian Biomes:

see_brazil_biomes()

image_tmin<- loadROI(variable = "eto", region = "biomes_brazil",
                      sub_region = 2)# sub regions: 1:6 (biomes)


## End(Not run)

Calculates the mean of the annual sum of the variables values

Description

The function calculates the mean of the annual sum of the variables of interest.

Usage

mean_of_annual_sum_of_variables(list_dir_of_imgs)

Arguments

list_dir_of_imgs

directory containing the images downloaded in download_terraclimate

Value

Returns a SpatRaster with the calculation.

Examples

## Not run: 

annual_mean_ppt<- mean_of_annual_sum_of_variables(list_dir_of_imgs = C:/ppt_dir);

## End(Not run)

Function to calculate the mean monthly rainfall/reference evapotranspiration to generate the crop water demand

Description

This function will calculate the mean monthly air temperature based on the period of time selected (start_date and end_date).

Usage

monthly_stack(stack, start_date, end_date)

Arguments

stack

Stack of mean rainfall/reference evapotranspiration SpatRaster

start_date

Date that start the investigation, should be in the following format (2000-01-01 /Year-Month-Day)

end_date

Date that end the investigation, should be in the following format (2017-12-31 /Year-Month-Day)

Value

Returns a SpatRaster with a monthly mean air temperature from a period of time

Examples

## Not run: 
start_date <- c('2000-01-01')
end_date <- c('2017-12-01')
monthly_rainfall <- monthly_stack(stack = rainfall_stack,
                                  start_date = start_date, end_date = end_date)

## End(Not run)

Function to plot the percentage of Available Water Capacity (AWC)

Description

This function will plot the monthly AWC

Usage

plot_AWC(AWC_stack)

Arguments

AWC_stack

A SpatRaster generated in WaterDemand function

Value

Returns a plot (gg file) of monthly percentage of AWC

Examples

## Not run: 
plot_AWC(AWC_stack)

## End(Not run)

Calibration of rainfall (ppt) of 'TerraClimate'

Description

This fuction will calibrate the rainfall (ppt) from TerraClimate dataset based in the relationship with observed weather stations data.

Usage

ppt_calibration(slope, intercept, ppt_stack)

Arguments

slope

the slope of the linear regression (numeric).

intercept

the intercept of the linear regression (numeric).

ppt_stack

stack of ppt.

Value

Returns a SpatRaster of ppt calibrated.

Examples

## Not run: 

ppt_cal<- ppt_calibration(slope = 0.7000972,
                          intercept = 23.753785, ppt_stack = ppt);

## End(Not run)

Function to see the Brazilian biomes available tp use in download.terraclimate and loadROI function

Description

This function will show the biomes available in the package and how we can call each biome polygon.

Usage

see_brazil_biomes()

Value

The biomes information available to run the cropDemand package.

Examples

## Not run: 
see_brazil_biomes()

## End(Not run)

Function to see the Brazilian states available to use in download.terraclimate and loadROI function

Description

This function will show the Brazilian state available in the package and how we can call each state polygon.

Usage

see_brazil_states()

Value

The Brazilian state information available in the package to run the cropDemand package.

Examples

## Not run: 
see_brazil_states()

## End(Not run)

Function to generate the water demand based in available water capacity of the soil

Description

This function will calculate the water balance parameters based in the available water capacity informed (AWC). The output water balance parameters for this function are:

  1. ARM - storage;

  2. ALT - alteration;

  3. ETR - actual evapotranspiration;

  4. DEF - deficit;

  5. EXC - excess;

  6. REP - replacement;

  7. RET - withdrawal;

  8. AWC_arm - percentage of storage compared to AWC;

Usage

waterDemand(out_dir, ppt_stack, eto_stack, AWC)

Arguments

out_dir

output directory where you want to save the variables

ppt_stack

Stack of mean rainfall Rasterstack calculated in monthly_stack function

eto_stack

Stack of mean evapotranspiration Rasterstack calculated in monthly_stack function

AWC

The available water capacity (AWC) that the function will use in the calculations. The AWC value must be chosen according to the crop (root system depth) you want to obtain the water balance.

Value

Returns multiple SpatRaster object as output (explained in description).

Examples

## Not run: 
cwd<- waterDemand(out_dir = "G:/My computer/test/CropWaterDemand",
                  ppt_stack = rainfall_image, eto_stack = eto_image, AWC = 100)

## End(Not run)