Description Usage Arguments Value Examples
View source: R/getDaylightHours.R
Returns the sunrise and sunset hours for specified dates within a bounding box based on sun ephemerides calculations. Sunrise is calculated using the midpoint of the east edge of the bounding box while sunset is calculated using the midpoint of the west edge.
The bounding box may be specified via any of the following methods:
Olson timezone, either as part of a POSIXt datetime, or specified
via the timezone
parameter
Geographic Bounding Box, either as a vector of floats in
c(lonLo, lonHi, latLo,latHi)
order, or the return value from
sp::bbox()
, or raster::extent()
Longitude and latitude specified in decimal degrees
If more than one of the above are specified, the order of preference for determining the bounding box is:
longitude, latitude
passed in – location +/- 0.1 degrees
bbox
passed in – use unchanged
timezone
passed in – use bbox of the timezone
datetime
is POSIXct
– use bbox of the timezone attribute
1 2 3 4 5 6 7 8 |
datetime |
Datetime as a Ymd HMS or Julian formatted string, or a
|
longitude |
Longitude of the location in decimal degrees E. |
latitude |
Latitude of the location in decimal degrees N. |
bbox |
Bounding box for the region. |
timezone |
Timezone used to interpret |
isJulian |
Logical flag determining whether |
List containing POSIXct
sunrise
and sunset
times
for the specified date.
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 | library(MazamaSatelliteUtils)
library(MazamaSpatialUtils)
# Get sunrise and sunset by lat/lon and datetime
getDaylightHours(
datetime = "2019-09-06",
longitude = -123.245,
latitude = 42.861
)
# Get sunrise and sunset by bbox and datetime
getDaylightHours(
datetime = "2019-09-06",
bbox = c(-124.566, -116.463, 41.991, 46.292) # Oregon
)
# Get sunrise and sunset by datetime and timezone
getDaylightHours(
datetime = "2019-09-06",
timezone = "America/Los_Angeles"
)
# Get sunrise and sunset for a vector of datetimes
getDaylightHours(
datetime = c("2019-06-21", "2019-09-23", "2019-12-22"),
longitude = -123.245,
latitude = 42.861
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.