Code Monkey home page Code Monkey logo

maas-seafarer's Introduction

Seafarer ⛵

Taxicab metric on the sphere! Install via

pip install seafarer

This library calculates the "seafarer distance" between two points on Earth: Travel parallel to latitude and longitude instead of "as the crow flies" – like in the old days...

Usage

Calculate the distance between Schwerin and Helsinki:

from seafarer import seafarer_metric

schwerin = (53.629722, 11.414722) # (lat, lon)
helsinki = (60.170278, 24.952222)

seafarer_metric(schwerin, helsinki)
# 1474.7398906623202 kilometres

You can also obtain the result in different units:

seafarer_metric(schwerin, helsinki, unit="mi")
# 916.3608837507956 miles
seafarer_metric(schwerin, helsinki, unit="ft")
# 4838385.468052049 feet

Seafarer is using the haversine library under the hood and you can use their Unit directly:

from haversine import Unit
seafarer_metric(schwerin, helsinki, unit=Unit.NAUTICAL_MILES)
# 796.2958366185961 nautical miles

What is this? Why Seafarer?

On a 2-dimensional plane, the metric obtained when travelling along the axes is known as taxicab, Manhattan, or L1 metric. What is the equivalent on a 3-dimensional sphere?

We calculate the distance when travelling along the grid of longitudinal and latitudinal lines. When travelling from Schwerin (53°N 11°E) to Helsinki (60°N 24°E) in the example above, there are two possiblities: travel via 53°N 24°E or 60°N 11°E. Unlike the 2D case, these two distances are (generally) different, so we use the short one.

Before navigation improved to a sufficient degree, this is how ships were sailing: parallel to the equator until they hit the target meridian, then North or South to their final destination. Hence seafarer metric! ⛵

maas-seafarer's People

Contributors

markusshepherd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.