Last active
June 2, 2020 20:10
-
-
Save korenmiklos/07acaae46a1c09dc2a121490eafc1393 to your computer and use it in GitHub Desktop.
Example illustrating geospatial concepts in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from shapely.geometry import Point | |
# suppose function projection(lat, lon) is already defined, returing (x, y) in meters | |
neighborgood_gps = (48.2176956, 16.3901985) | |
# a list of GPS coordinate pairs | |
transitstops_gps = [(), (), ..., ()] | |
neighborhood_shapely = Point(projection(neighborgood_gps)) | |
for point in transitstops_gps: | |
# first project to equidistant coordinates. then create a shapely Point. then measure distance to existing shapely Point. | |
distance = Point(projection(point)).distance(neighborhood_shapely) | |
print(distance) | |
closest_stops = [stop['neighbourhood'] for stop in berlin_data if distance(stop, hotel) < 1.0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment