Skip to main content

GeoDist Package

Project description

Geodist

Finds the distance between a POI (point of interest) and a geometric shape on Earth's surface

Objective

Find the distance between a point of interest and a geometric shape – polygon, circle, line string and a Point on earth’s surface using latitude and longitude associated with the geographic coordinate system

Install

pip install geodist

How Does It Work?

First, we convert an array of points (lng, lat) to a planar geometric object.

Then, we project the geometric object from the World Geodetic System (aka: WGS84) to the World Azimuthal Equidistant Projection (aka: ESRI:54032) with our POI as the center point of the projection.

The azimuthal equidistant projection is a map projection where all points on the map are at proportionally correct distances from the center.

HowDoesItWork

Examples

Polygon

The distance between a polygon and a POI

>>> from geodist import GeoDist
>>> coords = [(4.3466824, 50.8584046), (4.3371552, 50.8490306), (4.3429917, 50.8336379), (4.3488282, 50.8330958),
...           (4.3658226, 50.8409013), (4.3695992, 50.8473506), (4.3679684, 50.8526612), (4.3466824, 50.8584046)]
... 
>>> lng, lat = 4.3821081, 50.8133681
>>> GeoDist(coords).distance(lng, lat)
3153.3015428957347

Polygon

Circle

The distance between circles and a POI

>>> from geodist import GeoDist
>>> coords = [(-77.120923, 39.056418)]
>>> lng, lat = -77.145146, 39.047193
>>> GeoDist(coords, radius=1000).distance(lng, lat)
1334.582257003439
>>> GeoDist(coords, radius=2000).distance(lng, lat)
335.7868006642301
>>> GeoDist(coords, radius=3000).distance(lng, lat)
663.0086557682768

Another feature of GeoDist can tell if the POI is inside or outside the shape:

>>> a = GeoDist(coords, radius=1000)
>>> distance = a.distance(lng, lat)
>>> a.within
False

>>> b = GeoDist(coords, radius=3000)
>>> distance = b.distance(lng, lat)
>>> b.within
True

Circle

Linestring

The distance between a Linestring and a POI

>>> from geodist import GeoDist
>>> coords = [(-121.77919, 36.24285), (-121.77939, 36.24317), (-121.77955, 36.24336), (-121.77967, 36.24347),
          (-121.77977, 36.24358), (-121.78, 36.24378), (-121.78033, 36.24409), (-121.78052, 36.24433),
..............]
>>> lng, lat = -121.88728, 37.33901
>>> GeoDist(coords).distance(lng, lat)
39603.30198998547

Linestring

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geodist-0.4.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

geodist-0.4-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file geodist-0.4.tar.gz.

File metadata

  • Download URL: geodist-0.4.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.3

File hashes

Hashes for geodist-0.4.tar.gz
Algorithm Hash digest
SHA256 98be629f14f7f84a91dc248a6ae3b07bdee5976a592c6633e81492f0f8a0278d
MD5 2008a13e7710902e9735dba21dc75703
BLAKE2b-256 b6e798f1a6034827ef58eec0faa80de16a3b7ec3f49be895c46a50e9182bf676

See more details on using hashes here.

File details

Details for the file geodist-0.4-py3-none-any.whl.

File metadata

  • Download URL: geodist-0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.3

File hashes

Hashes for geodist-0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 79cef1994915532046fc6aafa69c9a7ec9fa3a48b97f23a2db31b40b6e947320
MD5 6170519507a4881f576f1862a0b9de39
BLAKE2b-256 6cc12285605d30e8e2ca0f8783c2e7c0ee5c0035ff581f9b4440778dfb7aba15

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page