From cf36eceb77364611c1d76cad2cea5c73ee2d5f8d Mon Sep 17 00:00:00 2001 From: Karan Jayachandra Date: Mon, 25 Sep 2023 15:33:31 +0200 Subject: Added the blog posts from the previous site --- content/blog/road_network/index.md | 33 +++++++++++++++++++++++++++++ content/blog/road_network/road_network.png | Bin 0 -> 2385072 bytes 2 files changed, 33 insertions(+) create mode 100644 content/blog/road_network/index.md create mode 100644 content/blog/road_network/road_network.png (limited to 'content/blog/road_network') diff --git a/content/blog/road_network/index.md b/content/blog/road_network/index.md new file mode 100644 index 0000000..fda7616 --- /dev/null +++ b/content/blog/road_network/index.md @@ -0,0 +1,33 @@ ++++ +title = "Road Network" +date = 2021-10-06T09:38:45+02:00 ++++ + +**The Gist:** I was inspired to create a poster that was based on a reddit post. I document the process here. + +![Road Network](road_network.png) + +Some time ago, I came across a [post](https://www.reddit.com/r/dataisbeautiful/comments/lnlkp5/mapping_the_main_roads_of_the_world_oc/) on the subreddt r/dataisbeautiful and liked the aesthetics of the visualization. I thought this would make for a very good poster especially if the location meant something to the owner. Therefore, I started digging into how I could make one for myself. Using data sets form governmental agencies seemed too time consuming. However while I was mindlessly searching the internet, I came across the python library called [OSMNX](https://osmnx.readthedocs.io/en/stable/) that directly accesses data from OpenStreetMap and can fetch the data without much hassle. However installing this package took me quite sometime to figure out mainly because of dependencies. I am not used to working with such libraries. Luckily this [blog](https://geoffboeing.com/2016/11/osmnx-python-street-networks/) post helped me quite a bit. + +```python {linenos=table} +import osmnx as ox + +centerPoint = (12.964398125325351, 77.57567696953713) + +place = ox.graph_from_point(centerPoint, dist=20000, + network_type='drive') +ox.plot_graph( + place, + figsize=(17, 24), + dpi=400, + edge_linewidth=0.2, + bgcolor='#FFFFFF', + node_color='none', + edge_color='#FF0000', + save=True, + filepath='roadNetwork.png', + close=True, + ) +``` + +With this and very few lines of code, I was able to make my own road network image of my favourite city Bengaluru. The first line imports the library. Based on the *centerPoint* and the *dist* variable that decides the radius from the center, the roads that allow for driving are fetched. This is then plotted with a specification of color, quality and size. I then used Canva to add the title and frame and voila. Although the original image was of much higher quality, I compressed it before adding it to the blog so that you can have faster loading time. Please note that the code takes some time to run because of the huge amount of data it needs to fetch. I am sure there is a better way to accomplish what I wanted to do. Please do reach out to me using the links in the footer if you have any constructive criticism. Thanks! diff --git a/content/blog/road_network/road_network.png b/content/blog/road_network/road_network.png new file mode 100644 index 0000000..14218b8 Binary files /dev/null and b/content/blog/road_network/road_network.png differ -- cgit v1.3.1