egm96

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2020 License: MIT Imports: 11 Imported by: 4

README

EGM96

This package egm96 provides a Go representation of the EGM96 geopotential model of the Earth. It calculates the geoid height of the 1996 Earth Gravitational Model (EGM96) for a given latitude and longitude.

The EGM96 Model

The EGM96 model is a component of the 1984 World Geodetic System (WGS84). The EGM96 homepage is at https://cddis.nasa.gov/926/egm96/egm96.html.

WGS84 defines a datum surface which is an ellipsoid whose center coincides with the Earth's center of mass. EGM96 defines a "geoid," a gravitational equipotential surface, relative to this datum surface. As an equipotential surface, the geoid also corresponds to Mean Sea Level.

EGM96 is specified as a spherical harmonics series of degree 360. The National Geospatial-Intelligence Agency (NGA), which is responsible for the model, also publishes a grid of the computed geoid heights at a 15'x15' resolution, from which the geoid height at any location can be interpolated.

This package calculates the geoid height at any location via interpolation of the NGA grid. Currently, a bilinear interpolation is used.

Usage

The most common usage will be to create a location corresponding to a GPS-derived latitude, longitude, and height-above-ellipsoid, and then calculate the height above MSL:

loc := NewLocationGeodetic(-12.25, 82.75, 10500*Ft)
h, err := loc.HeightAboveMSL()

Testing and Validation

The heights produced by this program have been validated against online calculator at https://www.unavco.org/software/geodetic-utilities/geoid-height-calculator/geoid-height-calculator.html

The EGM96 model and associated data files are produced by the US Government and are not subject to copyright. The software in this package is provided under the MIT license where applicable.

Documentation

Overview

Package egm96 provides a representation of the 1996 Earth Gravitational Model (EGM96), a geopotential model of the Earth.

EGM96 is the geoid reference model component of the World Geodetic System (WGS84). It consists of n=m=360 spherical harmonic coefficients as published by the National Geospatial-Intelligence Agency (NGA). The NGA also publishes a raster grid of the calculated heights which can be interpolated to approximate the geoid height at any location.

In effect, this model provides the height of sea level above the WGS84 reference ellipsoid. It is used, for example, in GPS navigation to provide the height above sea level.

This package is based on the NGA-provided 15'x15' resolution grid encoding the heights of the geopotential surface at each lat/long, and interpolates between grid points using a bilinear interpolation.

Index

Constants

View Source
const (
	A  = 6378137           // Equatorial radius of WGS84 reference ellipsoid in meters
	F  = 1 / 298.257223563 // Flattening of WGS84 reference ellipsoid
	E2 = F * (2 - F)       // Eccentricity squared of WGS84 reference ellipsoid
)

Constants defining the WGS84 reference ellipsoid

View Source
const (
	Deg = 1 / 57.29577951308232 // number of radians per degree
	Ft  = 0.3048                // number of meters per foot
)

Factors for converting between radians and degrees and between meters and feet.

Variables

This section is empty.

Functions

func DMSToDegrees

func DMSToDegrees(d, m, s float64) (dd float64)

DMSToDegrees converts integral degrees d, minutes m and seconds s (all of type float64) to a float-valued degrees amount.

If d<0 then must pass m>0 and s>0; if d==0 and m<0 then must pass s>0.

func DegreesToDMS

func DegreesToDMS(dd float64) (d, m, s float64)

DegreesToDMS converts float degrees dd to whole degrees d, minutes m and decimal seconds s (all of type float64).

Types

type Location

type Location struct {
	// contains filtered or unexported fields
}

Location is a type that represents a position in space as represented by a latitude, a longitude and a height.

func NewLocationGeodetic

func NewLocationGeodetic(latitude, longitude, height float64) (loc Location)

NewLocationGeodetic returns a Location given an input latitude, longitude, and height specified in the Geodetic system.

The Geodetic coordinate system is the usual latitude, longitude, and height above the WGS84 Reference Ellipsoid, i.e. as typically measured by a GPS receiver.

Latitude and longitude are specified in decimal degrees and height in meters.

Geodetic coordinates are the un-primed variables φ,λ,h in the WMM paper.

func NewLocationMSL

func NewLocationMSL(latitude, longitude, height float64) (loc Location, err error)

NewLocationMSL returns a Location given an input latitude, longitude, and height above mean sea level.

The latitude and longitude are as specified in the Geodetic Coordinate System, and the height is the height above mean sea level, NOT above the WGS84 Reference Ellipsoid.

Latitude and longitude are specified in decimal degrees and height in meters.

func (Location) Equals

func (l Location) Equals(ll Location) bool

Equals returns whether the latitude, longitude and height of the input location are equal to those of the caller.

func (Location) Geodetic

func (l Location) Geodetic() (phi, lambda, r float64)

Geodetic returns the location's lat (latitude), lng (longitude), and h (height). lat and lng are in radians and r is in meters. Geodetic coordinates are the variables φ,λ,h in the WMM paper.

func (Location) HeightAboveMSL

func (l Location) HeightAboveMSL() (h float64, err error)

HeightAboveMSL calculates the height of the EGM96 geoid at the input Location, which corresponds to the height of MSL relative to the WGS84 reference ellipsoid. It then subtracts this height from the total height above the WGS84 reference ellipsoid at the input Location, giving the the height above MSL.

func (Location) NearestEGM96GridPoint

func (l Location) NearestEGM96GridPoint() (loc Location, err error)

NearestEGM96GridPoint looks up the grid point nearest the desired location within the 15'x15' resolution grid data for the EGM96 geoid model.

The returned Location contains the lat/long of the grid point and the height in meters of the geoid relative to the WGS 84 reference ellipsoid at that grid point.

Ignores any height value in the input Location.

func (Location) Spherical

func (l Location) Spherical() (phi, lambda, r float64)

Spherical returns the location's phi (φ', corresponding to latitude), lambda (λ, equal to geodetic longitude), and r (r, distance from center of WGS sphere). phi and lambda are in radians and r is in meters. Spherical coordinates are the variables φ',λ,r in the WMM paper.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL