Skyfield: HomeTable of ContentsChangelogAPI Reference

API Reference — Geographic Locations

skyfield.toposlib.wgs84 = <skyfield.toposlib.Geoid object>

World Geodetic System 1984 Geoid.

This is the standard geoid used by the GPS system, and is likely the standard that’s intended if you are supplied a latitude and longitude that don’t specify an alternative geoid.

skyfield.toposlib.iers2010 = <skyfield.toposlib.Geoid object>

International Earth Rotation Service 2010 Geoid.

class skyfield.toposlib.Geoid(name, radius_m, inverse_flattening)

An Earth ellipsoid: maps latitudes and longitudes to (x,y,z) positions.

Instead of creating their own geoid object, most Skyfield users simply use the wgs84 object that comes built-in.

The math for turning a position into latitude and longitude is based on Dr. T.S. Kelso’s quite helpful article Orbital Coordinate Systems, Part III.

subpoint()

Deprecated since version 1.40: Renamed to geographic_position_of().

polar_radius

The Earth’s polar radius, as a Distance.

latlon(latitude_degrees, longitude_degrees, elevation_m=0.0, cls=<class 'skyfield.toposlib.GeographicPosition'>)

Return a GeographicPosition for a given latitude and longitude.

The longitude and latitude should both be specified in degrees. If no elevation in meters is supplied, the returned position will lie on the surface of the ellipsoid. Longitude is positive towards the east, so supply a negative number for west:

from skyfield.api import wgs84
observatory = wgs84.latlon(37.3414, -121.6429)  # 121.6° West

You can avoid remembering which directions are negative by using Skyfield’s compass direction constants, which have the values +1 and −1:

from skyfield.api import N, S, E, W
observatory = wgs84.latlon(37.3414 * N, 121.6429 * W)
latlon_of(position)

Return the latitude and longitude of a position.

The position’s .center must be 399, the center of the Earth. Geodetic latitude and longitude are returned as a pair of Angle objects.

height_of(position)

Return the height above the Earth’s ellipsoid of a position.

The position’s .center must be 399, the center of the Earth. A Distance is returned giving the position’s geodetic height above the Earth’s surface.

geographic_position_of(position)

Return the GeographicPosition of a position.

The position’s .center must be 399, the center of the Earth. A GeographicPosition is returned giving the position’s geodetic latitude and longitude, and an elevation above or below the surface of the ellipsoid.

subpoint_of(position)

Return the point on the ellipsoid directly below a position.

The position’s .center must be 399, the center of the Earth. Returns a GeographicPosition giving the geodetic latitude and longitude that lie directly below the input position, and an elevation above the ellipsoid of zero.

class skyfield.toposlib.GeographicPosition(model, latitude, longitude, elevation, itrs_xyz)

A latitude-longitude-elevation position on Earth.

Each instance of this class holds an (x,y,z) vector for a geographic position on, above, or below the Earth’s surface, in the ITRS reference frame: the international standard for an Earth-centered Earth-fixed (ECEF) reference frame. Instead of instantiating this class directly, Skyfield users usually give a reference geoid the longitude and latitude they are interested in:

from skyfield.api import wgs84
topos = wgs84.latlon(37.3414, -121.6429)

Once a geographic position has been created, here are its attributes and methods:

model

The Geoid, like WGS84 or IERS2010, that this position uses to map longitude, latitude, and elevation to a three-dimensional Cartesian position.

latitude

An Angle specifying latitude; the north pole has latitude +90°.

longitude

An Angle specifying longitude; east is positive, west is negative.

elevation

A Distance specifying elevation above (positive) or below (negative) the surface of the Earth ellipsoid specified by this position’s model.

itrs_xyz

A Distance object giving the spatial (x,y,z) coordinates of this location in the ITRS Earth-centered Earth-fixed (“ECEF”) reference frame.

center

The integer 399, which identifies this position as geocentric: its (x,y,z) coordinates are measured from the Earth’s center.

at(t)

Return the position of this Earth location at time t.

lst_hours_at(t)

Return the Local Apparent Sidereal Time, in hours, at time t.

This location’s Local Apparent Sidereal Time (LAST) is the right ascension of the zenith at the time t, as measured against the “true” Earth equator and equinox (rather than the fictional “mean” equator and equinox, which ignore the Earth’s nutation).

refract(altitude_degrees, temperature_C, pressure_mbar)

Predict how the atmosphere will refract a position.

Given a body that is standing altitude_degrees above the true horizon, return an Angle predicting its apparent altitude given the supplied temperature and pressure, either of which can be the string 'standard' to use 10°C and a pressure of 1010 mbar adjusted for the elevation of this geographic location.

rotation_at(t)

Compute rotation from GCRS to this location’s altazimuth system.

class skyfield.toposlib.ITRSPosition(itrs_xyz)

An (x,y,z) position in the Earth-centered Earth-fixed (ECEF) ITRS frame.

This (x,y,z) vector has no knowledge of standard geoids, latitude, or longitude, but is convenient if you already know the rectangular coordinates of a target’s location:

from skyfield.api import Distance
from skyfield.toposlib import ITRSPosition

d = Distance(km=[-3918, -1887, 5209])
p = ITRSPosition(d)
at(t)

Return the GCRS position of this ITRS coordinate at time t.