Module openquake.hazardlib.geo.geodetic contains functions for geodetic transformations, optimized for massive calculations.
Earth radius in km.
Store a collection of geographic objects, i.e. objects with longitudes and latitudes. By default extracts the coordinates from the attributes .lon and .lat, but you can provide your own getters. It is possible to extract the closest object to a given location by calling the method .get_closest(lon, lat).
Get the closest object to the given longitude and latitude and its distance. If the max_distance is given and all objects are farther than the maximum distance, returns (None, None).
Parameters: 


Calculate the azimuth between two points or two collections of points.
Parameters are the same as for geodetic_distance().
Implements an “alternative formula” from http://williams.best.vwh.net/avform.htm#Crs
Returns:  Azimuth as an angle between direction to north from first point and direction to the second point measured clockwise in decimal degrees. 

Calculate a distance between two points (or collections of points) considering points’ depth.
Calls geodetic_distance(), finds the “vertical” distance between points by subtracting one depth from another and combine both using Pythagoras theorem.
Returns:  Distance in km, a square root of sum of squares of geodetic distance and vertical distance, which is just a difference between depths. 

Calculate a closest distance between a great circle arc and a point (or a collection of points).
Parameters: 


Returns:  Distance in km, a scalar value or numpy array depending on plons and plats. A distance is negative if the target point lies on the right hand side of the arc. 
Solves a spherical triangle formed by reference point, target point and a projection of target point to a reference great circle arc.
In this method we use a reference system centerd on (alon, alat) and with the yaxis corresponding to aazimuth direction to calculate the minimum distance from a semiarc with generates in (alon, alat).
Parameters are the same as for distance_to_arc().
Calculate the geodetic distance between two points or two collections of points.
Parameters are coordinates in decimal degrees. They could be scalar float numbers or numpy arrays, in which case they should “broadcast together”.
Implements http://williams.best.vwh.net/avform.htm#Dist
Returns:  Distance in km, floating point scalar or numpy array of such. 

Find a list of points between two given ones that lie on the same great circle arc and are equally spaced by length km.
Parameters: 


Returns:  Tuple of three 1d numpy arrays: longitudes, latitudes and depths of resulting points respectively. 
Rounds the distance between two reference points with respect to length and calls npoints_towards().
Calculate the minimum distance between a collection of points and a point.
This function allows to calculate a closest distance to a collection of points for each point in another collection. Both collection can be of any shape, although it doesn’t make sense to use scalars for the first one.
Implements the same formula as in geodetic_distance() for distance along great circle arc and the same approach as in distance() for combining it with depth distance.
Parameters: 


Returns:  Minimum distance in km or indices of closest points, depending on indices parameter. Result value is a scalar if slons, slats and sdepths are scalars and numpy array of the same shape of those three otherwise. 
This function computes the shortest distance to a segment in a 2D reference system.
Parameters: 


Returns:  An array of the same shape as lons which contains for each point defined by (lons, lats) the shortest distance to the segment. Distances are negative for those points that stay on the ‘left side’ of the segment direction and whose projection lies within the segment edges. For all other points, distance is positive. 
Same as min_distance(), but calculates only minimum geodetic distance (doesn’t accept depth values) and doesn’t support indices=True mode.
This is an optimized version of min_distance() that is suitable for calculating the minimum distance between first mesh and each point of the second mesh when both are defined on the earth surface.
Find a list of specified number of points between two given ones that are equally spaced along the great circle arc connecting given points.
Parameters: 


Returns:  Tuple of three 1d numpy arrays: longitudes, latitudes and depths of resulting points respectively. 
Finds distance between two reference points and calls npoints_towards().
Find a list of specified number of points starting from a given one along a great circle arc with a given azimuth measured in a given point.
Parameters: 


Returns:  Tuple of three 1d numpy arrays: longitudes, latitudes and depths of resulting points respectively. 
Implements “completely general but more complicated algorithm” from http://williams.best.vwh.net/avform.htm#LL
Perform a forward geodetic transformation: find a point lying at a given distance from a given one on a great circle arc defined by azimuth.
Parameters: 


Returns:  Tuple of two float numbers: longitude and latitude of a target point in decimal degrees respectively. 
Implements the same approach as npoints_towards().