- 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.
- 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/
- 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:
![]()
There are many types of roads: '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'
- Filter relevant road types and plot with matplotlib:
- Iterate through all selected road types and split the polyline into 500 meters segments. The following figure plots segmented polylines :-
- Write out all the segments to a CSV file.