Metadata-Version: 2.1
Name: geodist
Version: 0.2
Summary: GeoDist Package
Home-page: https://github.com/dorhay/geodist
Author: Dor Hay
Author-email: dorhay@gmail.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Requires-Dist: pyproj
Requires-Dist: shapely

# 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](docs/images/objective.png)

## 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](docs/images/polygon_example.png)

### 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](docs/images/circle_example.png)

### 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](docs/images/linestring_example.png)


