getDaylightHours.Rd
Returns the sunrise and sunset hours for specified dates within a bounding box based on sun ephemerides calculations. Sunrise is calcualted 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
getDaylightHours( datetime = NULL, longitude = NULL, latitude = NULL, bbox = NULL, timezone = NULL, isJulian = FALSE )
datetime | Specific date for which daylight hours are requested. |
---|---|
longitude | Longitude of the location of interest in decimal degrees E. |
latitude | Latitude of the location of interest in decimal degrees N. |
bbox | Bounding box for the region of interest, Default: CONUS. |
timezone | Timezone in which to interpret the |
isJulian | Logical value determining whether datetime should be interpreted as a Julian date with day of year as a decimal number. |
List containing POSIXct
sunrise
and sunset
times
for the specified date.
# \donttest{ library(MazamaSatelliteUtils) library(MazamaSpatialUtils) # Get sunrise and sunset by lat/lon and datetime getDaylightHours( datetime = "2019-09-06", longitude = -123.245, latitude = 42.861 )#> $sunrise #> [1] "2019-09-06 06:42:25 PDT" #> #> $sunset #> [1] "2019-09-06 19:39:05 PDT" #># Get sunrise and sunset by bbox and datetime getDaylightHours( datetime = "2019-09-06", bbox = c(-124.566, -116.463, 41.991, 46.292) ) # Oregon#> $sunrise #> [1] "2019-09-06 06:14:30 PDT" #> #> $sunset #> [1] "2019-09-06 19:45:28 PDT" #># Get sunrise and sunset by datetime and timezone getDaylightHours( datetime = "2019-09-06", timezone = "America/Los_Angeles")#> $sunrise #> [1] "2019-09-06 06:07:52 PDT" #> #> $sunset #> [1] "2019-09-06 19:43:11 PDT" #># 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 )#> $sunrise #> [1] "2019-06-21 05:33:49 PDT" "2019-09-23 07:00:52 PDT" #> [3] "2019-12-22 07:40:45 PST" #> #> $sunset #> [1] "2019-06-21 20:55:21 PDT" "2019-09-23 19:08:41 PDT" #> [3] "2019-12-22 16:42:01 PST" #># }