gis-ops / routingpy

🌎 Python library to access all public routing, isochrones and matrix APIs in a consistent manner.
https://routingpy.readthedocs.io/en/latest/?badge=latest
Apache License 2.0
270 stars 26 forks source link

Calculate walking distance between two points #20

Closed lucaventimiglia closed 3 years ago

lucaventimiglia commented 3 years ago

Hi I would like to calculate walking distance between two points.

I copied and pasted the following code:

Here's what I did

`from routingpy import Graphhopper from shapely.geometry import Polygon

//Define the clients and their profile parameter apis = ( (Graphhopper(api_key='81d8fd41-33fb-4c98-b3a7-83b2e498cd14 '), 'bike'), ) //Define me locations in Berlin coords = [[13.413706, 52.490202], [13.421838, 52.514105], [13.453649, 52.507987], [13.401947, 52.543373]]

for api in apis: client, profile = api route = client.directions(locations=coords, profile=profile) print("Direction - {}:\n\tDuration: {}\n\tDistance: {}".format(client.class.name, route.duration, route.distance)) isochrones = client.isochrones(locations=coords[0], profile=profile, intervals=[600, 1200]) for iso in isochrones: print("Isochrone {} secs - {}:\n\tArea: {} sqm".format(client.class.name, iso.interval, Polygon(iso.geometry).area)) matrix = client.matrix(locations=coords, profile=profile) print("Matrix - {}:\n\tDurations: {}\n\tDistances: {}".format(client.class.name, matrix.durations, matrix.distances))`


Here's what I got

from routingpy import Graphhopper ImportError: cannot import name 'Graphhopper' from 'routingpy' (C:\Users\a463154\Desktop\Programmi Python\routing py\routingpy.py)

What is the problem in your opinion?

nilsnolde commented 3 years ago

Hm, smth looks off with the way python tries to import routingpy here: \routing py\routingpy.py. the folder doesn't exist, neither does the file routingpy.py. How did you install the package? Or try again with a pip install --force-reinstall routingpy?

lucaventimiglia commented 3 years ago

It worked by doing pip install --force-reinstall routingpy.

Thank you :)