


It has two classes called CompassSimple and CompassComplex.
#CIRCLE CALCULATOR CODE#
I thought it helped with code readability at first, kept it because it might be useful. This libaray was created to let me call, say Compass.east so I can get 90deg. unit is a unit of measurement that can be accessed by great_circle_units, default is 'meters'. Function point_given_start_and_bearing()įunction point_given_start_and_bearing(p1, course, distance, unit='meters') is given a start point p1, initial bearing course, and distance distance, this will calculate the destination point bearing travelling along a (shortest distance) great circle arc. fraction is the fraction of the distance between p1 and p2, where 0 is p1, 0.5 is equivalent to midpoint(), and 1 is p2. For example, say p3 = midpoint(p1, p2), distance_between_points(p1, p3) = distance_between_points(p2, p3) Function intermediate_point()įunction intermediate_point(p1, p2, fraction=0.5) an intermediate point along the course laid out by p1 to p2 given the fractional distance.

tuples, lists of length 2) in the form of (lon, lat) in decimal degrees. Function midpoint()įunction midpoint(p1, p2) is the half-way point along a great circle path between the two points. Use bearing_at_p1() to find the bearing at the starting point, p1.

Use in conjunction with midpoint() and intermediate_point() to find the course along the route. intermediate_point ( p1, p2, frac_along_route ), p2 ) Function bearing_at_p2įunction bearing_at_p2(p1, p2) computes the bearing (i.e. tuples, lists of length 2) in the form of (lon, lat) in decimal degrees.Įxample to find a course enroute: import great_circle_eat_circle_calculator as gcc """ This code snippit will find the the course at a point p3 which is 20% the way between points p1 and p2 """ p1, p2 = ( lon1, lat1 ), ( lon2, lat2 ) frac_along_route = 0.2 course_enroute = gcc. Use bearing_at_p2() to find the bearing at the endpoint, p2. Function bearing_at_p1()įunction bearing_at_p1(p1, p2) computes the bearing (i.e. Changing it to haversine=False yeilds the law of cosines which, typically, will have a quicker computational time. haversine=True uses the haversine formula, which is consideered superior for short distances (which is my often use case). tuples, lists of length 2) in the form of (lon, lat) in decimal degrees (That is, a tuple of float values, the library cannot handle DMS data). It will calculate the distance using the law of cosines unless the user specifies haversine to be true. The functions are distance_between_points, bearing_at_p1, bearing_at_p2, midpoint, intermediate_point, point_given_start_and_bearing Function distance_between_points()įunction distance_between_points(p1, p2, unit='meters', haversine=True) computes the distance between two points in the unit given in the unit parameter. Where * can be a specific function (or left as * for all the functions) Or from great_circle_eat_circle_calculator import * Library great_circle_calculatorĭepending on my needs, I will either import this library as import great_circle_eat_circle_calculator as gcc Here is an outline of the functions available to you. The convention of this package is for the spatial points to be represented as a tuple of length 2 with longitude being the first element and latitude being the second element, i.e.
#CIRCLE CALCULATOR HOW TO#
How to installĬlone/download the package to your project or use pip install great-circle-calculator ( PyPI) How to use
#CIRCLE CALCULATOR FREE#
One example is geodesy.Īny questions, feel free to get in touch. I believe there are more robust packages out there. Feel free to clone, fork, or modify the code as needed. The formulas here were adapted into python from here and here.īecause I've been using these equations across several projects, I decided to upload this to PyPI for ease of keeping updated and distribution. This is a collection of equations and formulas that I've been using across my many projects to compute various distances using great circle calculations.
