Skip to content

For a given geospatial location, calculate an isochrone (same time) contour around it.

Notifications You must be signed in to change notification settings

drewfustin/isocronut

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 

Repository files navigation

isocronut

For a given geospatial location, calculate an isochrone (same time) contour around it. Any point on an x-minute isochrone contour should take a total of x minutes of travel to reach from the origin. Any point within an x-minute contour should be reachable in fewer than x minutes.

Update: Javascript implementation

Thanks to help from wolframteetz, I've also created a more useable Mapbox/turf.js implementation which allows you to just click on a spot on a map and it calculates 30/60/90/120 minute isochrones real-time. It lives inside MapboxIsochrones.html. You can change the desired isochrone limits by editing the html itself. Also, make sure to insert your Mapbox access token into the html.

If you want to try it out yourself and are a Python noob, put the .html file in a folder. From the terminal, cd to that folder. If you're running Python 2, enter the command

python -m SimpleHTTPServer

or if you're running Python 3, enter the command

python3 -m http.server

Go to your favorite browser, and point it to http://localhost:8000/MapboxIsochrones.html. Click away on the map.

Use

import isocronut

origin = '111 W Washington, Chicago'
duration = 10

isochrone = isocronut.get_isochrone(origin, duration)
print isochrone

or generate your own html file with an embedded Google Maps with isochrone (which will be written to isochrone.html in the current directory):

import isocronut

origin = '111 W Washington, Chicago'
duration = 10

isochrone = isocronut.generate_isochrone_map(origin, duration)
print isochrone

Parameters

origin : Google Maps parseable origination address (str) or [lat, lng] 2-list ([scalar, scalar])

duration : Number of minutes (scalar) for the isochrone contour

number_of_angles : Number of points defining the isochrone (int) -- think of it as a resolution, default: 12

tolerance : Number of minutes (scalar) that a test point can be away from duration to be considered acceptable, default: 0.1

access_type : Either 'personal' or 'business' (str), specifying if you are using a personal or business API access for Google Maps (GeoCode API), default: 'personal'

  • If 'personal', you won't have access to traffic conditions. The format of the 'google_maps.cfg' config file must be (e.g. if your api_number were 1234567890, you would replace <your api number> below with 1234567890):
[api]
api_number=<your api number>
  • If 'business', you will be able to use current traffic conditions, which will tighten your contour distance. The format of the 'google_maps.cfg' config file must be:
[api]
client_id=<your client id>
crypto_key=<your crypto key>

config_path : Path location (str) of the 'google_maps.cfg' file, default 'config/'

Returns

Isochrone contour as a list of [lat, lng] 2-lists -- [[lat1, lng1], [lat2, lng2], ..., [latn, lngn]] where n = number_of_angles.

Dependencies

This module makes use of the following Python modules that you must have installed.

  • hashlib
  • hmac
  • base64
  • urlparse
  • ConfigParser
  • simplejson
  • urllib2
  • time
  • datetime
  • math

About

For a given geospatial location, calculate an isochrone (same time) contour around it.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •