Francesca Priante commited on
Commit
ab96ec4
1 Parent(s): 1649c1b

Add application file

Browse files
Files changed (2) hide show
  1. app_map.py +89 -0
  2. requirements.txt +2 -0
app_map.py ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ @author: Francesca Priante
5
+ """
6
+
7
+ import streamlit as st
8
+ import osmnx as ox
9
+ import io
10
+ import matplotlib.pyplot as plt
11
+
12
+ # To make it faster
13
+ ox.config(use_cache=True, log_console=True)
14
+
15
+
16
+ # %%
17
+ dpi = 100
18
+ walk=0.2
19
+
20
+ def show_city():
21
+ place = st.text_input('Insert adress here', value = 'Torino, via Roma')
22
+ dist = st.slider("Radius in meters", min_value= 500, max_value = 10000, value = 1000, step =100)
23
+ col1, col2, col3 = st.columns(3)
24
+
25
+ with col1:
26
+ bgcolor = st.color_picker('Background color','#000000')
27
+ with col2:
28
+ edgecol = st.color_picker('Streets colors','#FFFFFF')
29
+
30
+ street_widths = {'footway' : walk,
31
+ 'steps' : walk,
32
+ 'pedestrian' : walk,
33
+ 'path' : walk,
34
+ 'track' : 0.5,
35
+ 'service' : 0.5,
36
+ 'residential' : 0.5,
37
+ 'primary' : 1,
38
+ 'motorway' : 2,
39
+ 'cycleway' : 0.5,
40
+ 'steps' : walk,
41
+ 'corridor' : 0.5,
42
+ 'elevator' : 0.5,
43
+ 'escalator' : 0.5,
44
+ 'proposed' : 0.5,
45
+ 'construction' : 0.5,
46
+ 'bridleway' : 0.5,
47
+ 'abandoned' : 0.5,
48
+ 'platform' : 0.5,
49
+ 'raceway' : 0.5,
50
+ 'highway' : 2
51
+ }
52
+
53
+
54
+ fig, ax = ox.plot_figure_ground(address=place, network_type='all',
55
+ default_width=0.5, dpi=dpi, dist = dist, street_widths=street_widths,
56
+ edge_color=edgecol, bgcolor = bgcolor, smooth_joints=False)
57
+
58
+ st.pyplot(fig=fig, clear_figure=None)
59
+
60
+ fn = 'MAP.pdf'
61
+ plt.savefig(fn)
62
+ with open(fn, "rb") as img:
63
+ st.download_button(
64
+ label="Download image",
65
+ data=img,
66
+ file_name=fn,
67
+ mime="image/pdf"
68
+ )
69
+
70
+ fn = 'MAP.pdf'
71
+ img = io.BytesIO()
72
+ plt.savefig(img, format='pdf')
73
+
74
+ # Icons
75
+ # https://streamlit-emoji-shortcodes-streamlit-app-gwckff.streamlit.app/
76
+ st.set_page_config(page_title="Cool Maps", page_icon=":burrito:") # 📹
77
+ st.markdown("# Cool maps")
78
+ st.markdown(
79
+ """
80
+ Insert the address of the city of your interest and create minimalist maps.
81
+ You can also choose the background and streets colors. Then download it with the PDF button.
82
+
83
+ Keep in mind that it can take few minutes to display the map depending on how complex the city is. So the higher the radius, the slower it can be.
84
+
85
+ App developed with [Streamlit](https://github.com/streamlit/streamlit) and [OSMnx package](https://github.com/gboeing/osmnx) by [Francesca Priante](https://frapria.github.io/)
86
+ """
87
+ )
88
+
89
+ show_city()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ osmnx
2
+ matplotlib