Learn R Programming

barrks (version 1.1.0)

create_suntimes_rsts: Create rasters that indicate sunrise and sunset

Description

Generate a list of two multi-layer SpatRasters for a given template that indicate sunrise and sunset for the respective cells. The package suncalc is required to use this function.

Usage

create_suntimes_rsts(
  template,
  dates = terra::time(template),
  crs = "EPSG:4258",
  tz = Sys.timezone(),
  .quiet = FALSE
)

Value

A list with the elements sunrise and sunset which are both multi-layer SpatRasters. The values indicate the respective time in minutes. Each layer represents one date.

Arguments

template

(Multi-layer) SpatRaster that determines the spatial extent of the result.

dates

Dates that should be processed. If not specified, the dates of template are used through terra::time().

crs

Coordinate reference system with longitude/latitude metrics. It is used to project the raster coordinates to be able to retrieve longitude and latitude.

tz

Timezone of the results.

.quiet

If TRUE, messages are suppressed.

See Also

create_suntimes_df()

Examples

Run this code
if (FALSE) { # rlang::is_installed("suncalc")
# \donttest{
# calculate suntimes, use barrks_data()$tmin as template
st <- create_suntimes_rsts(barrks_data()[[1]], .quiet = TRUE)

# plot results on May 1st, 2015
terra::plot(st$sunrise[[terra::time(st$sunrise) == '2015-05-01']])
terra::plot(st$sunset[[terra::time(st$sunset) == '2015-05-01']])
# }
}

Run the code above in your browser using DataLab