This repository has been archived by the owner on May 5, 2022. It is now read-only.
forked from mehtab-alam/RSI-Tagger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.py
72 lines (58 loc) · 2.39 KB
/
App.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri May 7 22:11:50 2021
@author: syed
"""
import folium
import streamlit as st
from streamlit_folium import folium_static
import json
import os
print("streamlit=="+st.__version__)
print("folium=="+folium.__version__)
st.title("GeoTag - RSI Tagging")
list_country = os.listdir('geojson')
try:
list_country.remove('.DS_Store')
except:
print('Error')
list_country.sort()
option_country = st.selectbox("Select Country",(tuple(list_country)))
if option_country is not None:
list_city = os.listdir('geojson'+os.path.sep+option_country+os.path.sep+'cities')
try:
list_city.remove('.DS_Store')
except:
print('Error')
list_city.sort()
option_city = st.selectbox("Select City",list_city)
if option_city is not None:
list_cardinals_with_extensions = os.listdir('geojson'+os.path.sep+option_country.lower()+os.path.sep+'cities'+os.path.sep+option_city.lower())
list_cardinals = [x.split('.')[0] for x in list_cardinals_with_extensions]
list_cardinals.sort()
option_relative = st.selectbox("Select Relative position",list_cardinals)
if st.button('Draw Location'):
path = 'geojson/'+option_country.lower()+'/cities/'+option_city.lower()+'/'+option_relative.lower()+'.geojson'
#path1 = 'geojson/'+option_country.lower()+'/cities/'+option_city.lower()+'/south.geojson'
#path2 = 'geojson/'+option_country.lower()+'/cities/'+option_city.lower()+'/south-east.geojson'
#path3 = 'geojson/'+option_country.lower()+'/cities/'+option_city.lower()+'/south-west.geojson'
#path = 'geojson/'+option_country.lower()+'/'+option_relative.lower()+'.geojson'
#path = 'geojson/'+option_country.lower()+'/'+'centeral'+'.geojson'
with open(path) as f:
gj = json.load(f)
centroid = gj['features'][0]['properties']['centroid']
centroid = (centroid[0],centroid[1])
my_map = folium.Map(location=[centroid[1], centroid[0]],
zoom_start = 11)
folium.GeoJson(
path,
smooth_factor=1,
style_function = lambda x: {
'fillColor': 'green',
'color': 'black',
'weight': 2.5,
'fillOpacity': 0.3
},
name= option_city.lower()).add_to(my_map)
folium_static(my_map)