Skip to content

Instantly share code, notes, and snippets.

@clemsos
Created February 13, 2018 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clemsos/c252e131c58affc6ba092d9456f2bd16 to your computer and use it in GitHub Desktop.
Save clemsos/c252e131c58affc6ba092d9456f2bd16 to your computer and use it in GitHub Desktop.
Create NetworkX maps of Chinese cities
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Create maps of Chinese cities with OSMnx\n",
"\n",
"We focus on 3 main cities/regions : \n",
"\n",
"* HK/Shenzhen\n",
"* Shanghai \n",
"* Chengdu\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# search locations at https://nominatim.openstreetmap.org/\n",
"# ref : https://www.dengxiangxing.com/post/35986\n",
"\n",
"\n",
"import osmnx as ox\n",
"\n",
"dist = 3000\n",
"places = [\n",
" ('shanghai', (31.2253441,121.4888922), 'drive_service')\n",
" ('shenzhen', (22.5442673,114.0545327), 'drive_service')\n",
" ('chengdu', (30.6765553,104.0612783), 'drive_service')\n",
" ]\n",
"\n",
"for name, point, nt in places:\n",
"\n",
" # get the network\n",
" G = ox.graph_from_point(point, distance=dist, distance_type ='bbox', network_type=nt, truncate_by_edge=True)\n",
" G_projected = ox.project_graph(G)\n",
"\n",
" # plot it: nodes in this network are street junctions\n",
" fig, ax = ox.plot_graph(G_projected, node_size=8, node_color='k', node_zorder=2,\n",
" edge_color='gray', edge_linewidth=0.5, edge_alpha=0.8)\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment