-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove dependency on geopy #316
Conversation
powersimdata/utility/distance.py
Outdated
site_coords = (x.from_lat, x.from_lon) | ||
place2_coords = (x.to_lat, x.to_lon) | ||
return geopy.distance.vincenty(site_coords, place2_coords).km | ||
return haversine((x.from_lat, x.from_lon), (x.to_lat, x.to_lon)) * 1.60934 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we use a constant here? mi_to_km = 1.60934
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks for cleaning this up.
6f53f52
to
fce9060
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for cleaning this up
fce9060
to
afd24c6
Compare
Purpose
Reduce number/scope of required dependencies.
geopy
is "a Python client for several popular geocoding web services.geopy
makes it easy for Python developers to locate the coordinates of addresses, cities, countries, and landmarks across the globe using third-party geocoders and other data sources." We are using it to calculate the distance between two points.What is the code doing
In
distance.py
,great_circle_distance
takes a series with {from_lat, from_lon, to_lat, to_lon} and returns the distance between the two points. As far as I can tell, it's used only from within PostREISE. I've refactored it to use thehaversine
function/formula instead, and deleted thegeopy
import and requirements.Validation
Over our entire grid, the maximum length difference between vincenty and haversine methods is 0.4 miles, for a 211 mile line. The largest relative difference appears to be 0.4% on a zero-length line (floating point cruft?).
(run with develop):
Time to review
5 minutes.