View source: R/activity_code.r
get_suntimes | R Documentation |
Calculates approximate times of sunrise and sunset and day lengths for given dates at given locations.
get_suntimes(
date,
lat,
lon,
offset,
...,
tryFormats = c("%Y-%m-%d %H:%M:%OS", "%Y/%m/%d %H:%M:%OS",
"%Y:%m:%d %H:%M:%OS", "%Y-%m-%d %H:%M", "%Y/%m/%d %H:%M",
"%Y:%m:%d %H:%M", "%Y-%m-%d", "%Y/%m/%d", "%Y:%m:%d")
)
date |
character, POSIX or Date format date/time value(s) |
lat, lon |
latitude and longitude in decimal degrees |
offset |
the time offset in hours relative to UTC (GMT) for results |
... |
arguments passed to as.POSIXlt |
tryFormats |
formats to try when converting date from character, passed to as.POSIXlt |
Function adapted from https://www.r-bloggers.com/2014/09/seeing-the-daylight-with-r/
A dataframe with columns sunrise and sunset (given in the timezone defined by offset) and daylength, all expressed in hours.
Teets, D.A. 2003. Predicting sunrise and sunset times. The College Mathematics Journal 34(4):317-321.
data(BCItime)
dat <- subset(BCItime, species=="ocelot")$date
get_suntimes(dat, 9.156335, -79.847682, -5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.