Skip to contents

Get sunrise and sunset times by day, latitude, and longitude

Usage

get_sunrise_sunset(
  chosen_date,
  latitude = NULL,
  longitude = NULL,
  survey = NULL,
  station = NULL,
  verbose = FALSE,
  timezone = "US/Alaska"
)

Arguments

chosen_date

Date or charater. Formatted as "YYYY-MM-DD"

latitude

Numeric. Fill in only if survey and station are not entered. latitude in either decimal degrees or a character latitude in degrees and decimal minutes

longitude

Numeric. Fill in only if survey and station are not entered. Longitude in either decimal degrees or a character longitude in degrees and decimal minutes

survey

Character. Fill in only if latitude and longitude are not entered. A character string of the survey you are interested in reivewing. Options are those from public_data$survey, which are "AI", "GOA", "EBS", "NBS", "BSS".

station

Character. Fill in only if latitude and longitude are not entered. A character string of the current station name (as a grid cell; e.g., "264-85"). Stations defined in the station_coords dataset.

verbose

Logical. Default = FALSE. If you would like a readout of what the file looks like in the console, set to TRUE.

timezone

Character. Default = "US/Alaska." Other options include: "US/Aleutian"

Value

Time of sunrise and sunset in text. Also shows a pop-up with sunrise and sunset times.

Examples

# Find times based on lat/lon for today's date, where date is a date object
get_sunrise_sunset(chosen_date = Sys.Date(),
                   latitude = 63.3,
                   longitude = -170.5)
#> Using latitude and longitude to calcualte sunrise and sunset. 
#> Sunrise is at 2024-10-02 09:34:00 AKDT
#> Sunset is at 2024-10-01 20:48:00 AKDT

# Find times based on lat/lon for today's date, where date is a character
get_sunrise_sunset(chosen_date = "2023-06-05",
                   latitude = 63.3,
                   longitude = -170.5)
#> Using latitude and longitude to calcualte sunrise and sunset. 
#> Sunrise is at 2023-06-05 05:23:00 AKDT
#> Sunset is at 2023-06-05 01:17:00 AKDT
# Find times based on lat/lon for today's date, where date is a character
# and lat/lon in degree decimal-minutes
get_sunrise_sunset(chosen_date = "2023-06-05",
                   latitude = "63 18.0",
                   longitude = "-170 30.0")
#> Using latitude and longitude to calcualte sunrise and sunset. 
#> Sunrise is at 2023-06-05 05:19:00 AKDT
#> Sunset is at 2023-06-05 01:13:00 AKDT
# Find times based on a survey (EBS) station's recorded lat/lon for today's date
get_sunrise_sunset(chosen_date = Sys.Date(),
                   survey = "EBS",
                   station = "I-13")
#> Using survey station (EBS I-13) centroid location information (lat = 57.667, lon = -160.23) to calculate sunrise and sunset. 
#> Sunrise is at 2024-10-02 08:48:00 AKDT
#> Sunset is at 2024-10-01 20:12:00 AKDT
# Find times based on a survey (GOA) station's recorded lat/lon for today's date
get_sunrise_sunset(chosen_date = Sys.Date(),
                   survey = "GOA",
                   station = "323-176")
#> Using survey station (GOA 323-176) centroid location information (lat = 60.052, lon = -143.311) to calculate sunrise and sunset. 
#> Sunrise is at 2024-10-02 07:42:00 AKDT
#> Sunset is at 2024-10-01 19:02:00 AKDT
# Find times based on a survey (AI) station's recorded lat/lon for today's date
get_sunrise_sunset(chosen_date = "2023-06-10",
                    survey = "AI",
                   station = "33-47")
#> Using survey station (AI 33-47) centroid location information (lat = 53.013, lon = 172.407) to calculate sunrise and sunset. 
#> Sunrise is at 2023-06-10 08:05:00 AKDT
#> Sunset is at 2023-06-10 00:54:00 AKDT