impact_dt: Calculates impacts of cropland conversions

Description Usage Arguments Details Note Examples

View source: R/impact_dt.R

Description

Calculates impacts of cropland conversions

Usage

1
impact_dt(conv, carbon, pot_yield, div_list, cost, crop_frac, cropnames, ha)

Arguments

conv

data.table of cropland conversions

carbon

data.table of veg and soil carbon stocks

pot_yield

data.table of potential crop yields (modified as needed)

div_list

list of diversity data.tables

cropnames

Vector of crop names in analysis

ha

Pixel area

Details

Calculates summary statistics of the impacts of cropland conversions, including total tons carbon lost, carbon loss/ton crop yield, total area converted per crop, total area loss of PAs, mean diversity of converted pixels, mean diversity/ton crop yield

Note

Some estimate of fragmentation might be useful here. I have to fix impacts to not double-count where winter-crops are grown (wheat here)

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
rc <- run_code(input_key = "ZA")
il <- input_handler(input_key = "ZA", ybetas = c(1, 1), code = rc,
                    ybeta_update = 1)
CRSobj <- projection(raster("external/ext_data/ZA-carbon.tif"))
ha <- res(raster("external/ext_data/ZA-carbon.tif"))[2]^2 / 10000
prod_targ <- c("maize" = 4, "cassava" = 2, "ground" = 2, "cotton" = 2,
               "soy" = 2, "pulse" = 2,"sunflower" = 2, "sugarcane" = 2,
               "wheat" = 2)
ybetas <- list(1, 1)
cbetas <- c(1, 1, 0, 0)
names(cbetas) <- c("Ag", "C", "bd", "cost")
impnames <- c("carbon", "richness", "pas")

# target
target <- targets_dt(prod_targ = prod_targ, currprod = il$currprod,
                     potprod = il$pp_curr)
# constraints module
c_prob <- constraints_dt(inlist = il[c("y_std", "carbon_p", "cons_p",
                         "cost")],
                         cbetas = cbetas, code = rc,
                         cropnames = il$cropnames)

# convert module
converted <- convert_dt(conv_prob = c_prob, target = target,
                        crop_frac = il$cropfrac,
                        pot_yield = il$p_yield, cropnames = il$cropnames,
                        base = il$mask, ha = ha, keep_index = FALSE)
# impacts
impacts <- impact_dt(conv = converted,
                     carbon = il$carbon[, c("veg", "soil"), with = FALSE],
                     pot_yield = il$p_yield, div_list = il[impnames[2:3]],
                     crop_frac = il$cropfrac, cropnames = il$cropnames,
                     ha = ha)

marcusspiegel/agroEcoTradeoff documentation built on May 21, 2019, 11:44 a.m.