1. Start by downloading the administrative boundary data for the country in ESRI format from country. For more information about administrative divisions of different countries, see 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 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:

  1. Download and unzip it. There is a shapefile for road data in roads.*. Optionally we can drag and drop roads.* to view on You’ll see all roads map like this:

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:
  1. Iterate through all selected road types and split the polyline into 500 meters segments. The following figure plots segmented polylines :-
  1. Write out all the segments to a CSV file.