Description Usage Arguments Value Note Examples
For a particular combination of locations and dates, radii, and active
ingredients, write_exposure
calculates exposure (kg/m^2) and writes
out files (exposure values, meta data, and plots) to a specified directory.
1 2 3 4 5 6 7 8 9 10 11 | write_exposure(
clean_pur_df,
locations_dates_df,
radii,
directory,
chemicals = "all",
aerial_ground = FALSE,
write_plots = TRUE,
verbose = TRUE,
...
)
|
clean_pur_df |
A data frame returned by |
locations_dates_df |
A data frame with three columns: |
radii |
A vector of numeric values greater than zero that give the radii in meters defining the buffers around your locations in which you would like to calculate exposure. For reference, the length and width of a PLS section is about 1,609 meters (1 mile). That of a township could range from about 9,656 to 11,265 meters (6-7 miles). |
directory |
A path to the directory where you would like exposure files to be written. This directory will be created if it doesn't already exist. |
chemicals |
Either "all" or "chemical_class". The default is "all", which
will calculate exposure to the summed active ingredients present in the
|
aerial_ground |
TRUE / FALSE for whether you would like to
incorporate aerial/ground application into exposure calculations. If
|
write_plots |
TRUE / FALSE for whether you would like to write out
plots returned from |
verbose |
TRUE / FALSE for whether you would like a message to print out
while the function is running. The default is |
... |
Additional arguments passed on to |
Two .rds files ("exposure_df" and "meta_data") and a subdirectory
("exposure_plots") with PNG files of plot_exposure
plots:
A data frame with 10 columns: exposure
, the
exposure value in kg/m^2 for that combination of chemicals, date range,
aerial/ground application, location, and radius, chemicals
, either
"all" or a chemical class present in the provided clean_pur_df
data
frame, start_date
and end_date
, aerial_ground
, which
will be NA
unless the aerial_ground
argument is set to
TRUE
, location
, radius
, longitude
and
latitude
of each location, and any error_message
s that were
returned when calculating exposure.
A list with as many elements as there are rows in the
exposure_df.rds data frame. Each element is a data frame with meta data
relevant to the exposure value in the corresponding row of the exposure_df
data frame. For example, meta data for exposure_df[1,] is saved as
meta_data[[1]], exposure_df[2,] saved as meta_data[[2]], and so on. Meta
data data frames have 13 columns: pls
, with each PLS unit intersected
by the specified buffer, chemicals
, either a chemical class or "all"
(indicating exposure was calculated for all active ingredients present in
the clean_pur_df data frame), percent
, the percent intersection of
the PLS unit with the buffer, kg
, kg of active ingredients applied
in the PLS unit for the given date range/chemicals/aerial_ground combination,
kg_intersection
, percent
multiplied by kg
,
start_date
, end_date
, aerial_ground
(this will be
NA
if the aerial_ground
argument is set to FALSE
or if
none_recorded
is TRUE
), none_recorded
, a logical value
indicating if there were no active ingredients recorded for the
PLS/date range/chemicals combination, location
, radius
,
area
, the area of the specified buffer, and error_message
,
which gives the error message, if any, that was returned.
A subdirectory with a plot_exposure
plot saved
for each row of the exposure_df data frame and element of the meta_data list.
Plots are saved as #_exposure_plot.png, with numbers corresponding to the
row number and element number of the exposure_df data frame and meta_data
list, respectively. For example, 12_exposure_plot.png corresponds to
exposure_df[12,] and meta_data[[12]].
Unlike the calculate_exposure
function, write_exposure
requires that you specify at least one start and end date for each
location with the locations_dates_df
argument. This is to
accomodate multiple date ranges within a single location and
differing start/end dates across locations.
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 34 | library(magrittr)
chemical_class_df <- rbind(find_chemical_codes(2000:2001, "sulfur"),
find_chemical_codes(2000:2001, "methyl bromide"))
dplyr::rename(chemical_class = chemical)
pur <- pull_clean_pur(2000:2001, counties = "fresno",
chemicals = chemical_class_df$chemname,
sum_application = TRUE,
sum = "chemical_class",
chemical_class = chemical_class_df)
schools <- c("3333 American Ave., Fresno, CA 93725",
"1111 Van Ness Ave., Fresno, CA 93721",
"1616 South Fruit Ave., Fresno, CA 93706")
df <- data.frame(location = rep(schools, each = 2),
start_date = rep(c("2000-01-01", "2000-05-25", "2001-02-16"),
each = 2),
end_date = c("2000-04-01", "2000-07-01",
"2000-08-25", "2000-11-25",
"2001-05-16", "2001-08-16"))
temp_dir <- tempdir()
write_exposure(pur, df, c(1500, 3000), "chemical_class",
directory = temp_dir)
exposure_df <- readRDS(paste0(temp_dir, "/exposure_df.rds"))
meta_data <- readRDS(paste0(temp_dir, "/meta_data.rds"))
list.files(paste0(temp_dir, "/exposure_plots"))
spdf <- readRDS(system.file("extdata", "fresno_spdf.rds", package = "purexposure"))
pur <- readRDS(system.file("extdata", "fresno_clean.rds", package = "purexposure"))
df <- data.frame(location = "-119.726751, 36.660967",
start_date = "2000-01-01",
end_date = "2000-12-31")
temp <- tempdir()
write_exposure(pur, df, 3000, temp, spdf = spdf)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.