getMoonPosition: Get Moon position

View source: R/getMoonPosition.R

getMoonPositionR Documentation

Get Moon position

Description

Get Moon position

Usage

getMoonPosition(
  date = NULL,
  lat = NULL,
  lon = NULL,
  data = NULL,
  keep = c("altitude", "azimuth", "distance", "parallacticAngle")
)

Arguments

date

Single or multiple DateTime. Can be a Date (YYYY-MM-DD), a character in UTC (YYYY-MM-DD HH:mm:ss) or a POSIXct

lat

numeric. Single latitude

lon

numeric. Single longitude

data

data.frame. Alternative to use date, lat, lon for passing multiple coordinates

keep

character. Vector of variables to keep. See Details

Details

Returns an object with the following properties:

"altitude"

moon altitude above the horizon in radians

"azimuth"

moon azimuth in radians

"distance"

distance to moon in kilometers

"parallacticAngle"

parallactic angle of the moon in radians

Value

data.frame

See Also

Other suncalc functions: getMoonIllumination(), getMoonTimes(), getSunlightPosition(), getSunlightTimes()

Examples


# one date
getMoonPosition(date = Sys.Date(), lat = 50.1, lon = 1.83)

# in character
getMoonPosition(date = c("2017-05-12", "2017-05-12 00:00:00"), 
    lat = 50.1, lon = 1.83)

# in POSIXct
getMoonPosition(date = as.POSIXct("2017-05-12 00:00:00", tz = "UTC"),
    lat = 50.1, lon = 1.83)
getMoonPosition(date = as.POSIXct("2017-05-12 02:00:00", tz = "CET"),
    lat = 50.1, lon = 1.83)

# multiple date + subset
getMoonPosition(date = seq.Date(Sys.Date()-9, Sys.Date(), by = 1), 
  keep = c("altitude", "azimuth"), 
  lat = 50.1, lon = 1.83)
  
# multiple coordinates
data <- data.frame(date = seq.Date(Sys.Date()-9, Sys.Date(), by = 1), 
    lat = c(rep(50.1, 10), rep(49, 10)), 
    lon = c(rep(1.83, 10), rep(2, 10)))
    
getMoonPosition(data = data, 
  keep = c("altitude", "azimuth"))

      

suncalc documentation built on July 16, 2026, 5:06 p.m.