Skip to content

leonpalafox/isocronasmexicocity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mexico City Metro Map Tutorial

This repository contains a tutorial on how to create an interactive map of Mexico City's metro system using Python, GeoPandas, and Folium. The map includes metro stations and 15-minute walking isochrones for each station.

Google Colab Notebook

You can run this tutorial directly in your browser using Google Colab. Click the badge below to open the notebook:

Open In Colab

Prerequisites

  • Python 3.7+
  • GeoPandas
  • Folium
  • Requests

Installation

  1. Clone this repository:

    git clone https://github.com/yourusername/mexico-city-metro-map.git
    cd mexico-city-metro-map
    
  2. Install the required packages:

    pip install geopandas folium requests
    

Usage

  1. Convert the shapefile to GeoJSON:

    python convert_shapefile.py
    
  2. Create the interactive map:

    python create_map.py
    
  3. Open the generated mexico_city_metro_map.html file in your web browser to view the map.

Customizing the Map

Changing the Isochrone Radius

To change the isochrone radius (currently set to 15 minutes), modify the create_map.py file. Locate the following line in the create_map() function:

isochrone = get_isochrone(lat, lng, 15)  # 15-minute isochrone

Change the number 15 to your desired time in minutes. For example, to create 30-minute isochrones:

isochrone = get_isochrone(lat, lng, 30)  # 30-minute isochrone

Changing the Mode of Transportation

The current map uses walking as the mode of transportation for isochrones. To change this, you need to modify the API endpoint in the get_isochrone() function in create_map.py. Find this line:

url = "https://api.openrouteservice.org/v2/isochrones/foot-walking"

You can change foot-walking to one of the following options:

  • driving-car for driving
  • cycling-regular for cycling
  • foot-walking for walking (current setting)

For example, to change to driving:

url = "https://api.openrouteservice.org/v2/isochrones/driving-car"

Remember to adjust the isochrone time accordingly, as different transportation modes will cover different distances in the same time.

Files

  • README.md: This file, containing an overview and instructions.
  • convert_shapefile.py: Script to convert the shapefile to GeoJSON.
  • create_map.py: Script to create the interactive map with stations and isochrones.
  • Mexico_City_Metro_Map.ipynb: Jupyter notebook for running the tutorial in Google Colab.
  • STC_Metro_estaciones_utm14n.shp: Input shapefile (not included in the repository).
  • mexico_city_subway_stations.geojson: Output GeoJSON file (generated by convert_shapefile.py).
  • mexico_city_metro_map.html: Output HTML file containing the interactive map (generated by create_map.py).

Note

You'll need to obtain an API key from OpenRouteService and replace the placeholder in create_map.py with your actual key.

License

This project is open source and available under the MIT License.

About

Creacion de isocronas

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors