WorkflowΒΆ

  1. Start by downloading the administrative boundary data for the country in ESRI format from http://www.gadm.org/ country. For more information about administrative divisions of different countries, see https://en.wikipedia.org/wiki/Table_of_administrative_divisions_by_country There are multiple administrative levels — cities may be nested in states which may be nested in countries.
  2. Using pyshp package load 2nd level shapefile (IND_adm2.dbf and IND_adm2.shp), extract polylines of “NCT of Delhi” and build map data extract URL for http://extract.bbbike.org like the one for Delhi.

This is so that we don’t need to set up our own OSM map server, which is extremely large.

Get link to the extracted map data by e-mail or check the download status page: http://download.bbbike.org/osm/extract/

  1. Download and unzip it. There is a shapefile for road data in roads.*. Optionally we can drag and drop roads.* to view on http://www.mapshaper.org/. You’ll see all roads map like this:
_images/india-delhi-roads-plot-all.png

There are many types of roads found in the map data: ‘primary’, ‘pedestrian’, ‘bridleway’, ‘secondary_link’, ‘tertiary’, ‘primary_link’, ‘service’, ‘residential’, ‘motorway_link’, ‘cycleway’, ‘secondary’, ‘living_street’, ‘track’, ‘motorway’, ‘construction’, ‘tertiary_link’, ‘trunk’, ‘path’, ‘trunk_link’, ‘rest_area’, ‘footway’, ‘unclassified’, ‘steps’, and ‘road’

  1. Filter a few interesting road types and plot with matplotlib:
_images/india-delhi-roads-plot-selected-zoom-wgs84.png
  1. Iterate through all selected road types and split the polyline into 500 meters segments. The following figure plots segmented polylines :-
_images/india-delhi-roads-plot-selected-segmented-zoom-wgs84.png
  1. Write out all the segments to a CSV file.