View source: R/day_night_flag.R
| day_night_flag | R Documentation |
Creates a day/night indicator for each time point. If latitude and longitude are not provided, local time is used (daylight defined by an hour threshold). Otherwise, an approximate solar zenith angle is computed to determine whether the sun is above the horizon.
day_night_flag(data, date_col = NULL, lat = NULL, lon = NULL,
threshold = 6, type = c("binary", "sun", "shade"),
local_tz = "UTC", verbose = FALSE)
data |
A data frame with a time column. |
date_col |
Time column index or name. If |
lat |
Latitude of the location(s). Can be a scalar or a vector of length equal to the number of rows. |
lon |
Longitude of the location(s). Same behavior as |
threshold |
Hour threshold used for local-time based classification (default 6). Only used if latitude/longitude are missing. |
type |
Output type: |
local_tz |
Time zone for local time calculation (default UTC). |
verbose |
Logical; if |
When latitude/longitude are supplied, the function computes the solar zenith angle using a simplified astronomical formula. Values with a solar zenith angle below 90 degrees are considered day.
A vector of day/night flags.
Chun-Sheng Liang <chun-shengliang@qq.com>
1. Example data is from https://smear.avaa.csc.fi/download. It includes particle number concentrations in SMEAR I Varrio forest.
day_night_flag(data[1:100, c(1, 4, 17:19)], date_col = 1, lat = 40, lon = -105)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.