Skip to content

Commit

Permalink
add euclidean distance
Browse files Browse the repository at this point in the history
  • Loading branch information
TJhon committed Jul 10, 2023
1 parent 4681e94 commit ccd689d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 6 additions & 1 deletion osrmareas/areas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import geopandas as gpd, numpy as np
from shapely.geometry import LineString, Point
from shapely.geometry import Polygon
import geopy.distance

ecl_dist = geopy.distance.geodesic

crs_moll='EPSG:3857'
crs_lat='EPSG:4326'
Expand Down Expand Up @@ -41,7 +44,9 @@ def get_osrm_route(from_, to_, how='driving'):
# route.append([-66.744416, -54.975603])dd
line = gpd.GeoDataFrame(geometry=[LineString(route)]).set_crs(crs_lat)
line = line.assign(
dist_driving_km=dist/1000, dest_lon = to_[0], dest_lat = to_[1],
dist_driving_km=dist/1000,
dist_eucl_km = ecl_dist((to_[0], to_[1]), (from_[0], from_[1])).km, #euclidean distance
dest_lon = to_[0], dest_lat = to_[1],
origin_lon = from_[0], origin_lat = from_[1]
)
return line
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ geopandas
alphashape
shapely
tqdm
twine
twine
geopy
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
'geopandas',
'alphashape',
'shapely',
'tqdm'
'tqdm',
'geopy'
],
long_description='''
Using OSRM to create areas and routes within a radius.
Expand Down

0 comments on commit ccd689d

Please sign in to comment.