File size: 2,034 Bytes
572ad66
bb42d41
 
572ad66
2edc159
bb42d41
572ad66
72c1bbd
 
 
572ad66
508df8c
 
 
 
 
 
 
bb42d41
 
 
 
 
 
 
 
 
 
 
 
572ad66
 
 
 
 
 
 
a6a7c8c
 
 
 
bb42d41
 
 
572ad66
 
 
bb42d41
 
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
from os.path import join
import leafmap.foliumap as leafmap
import streamlit as st
import geopandas as gpd
st.set_page_config(layout="wide")

file_map = {"Ahmedabad 10 km buffer": "ahmedabad_10km_buffer.geojson",
            "Lucknow 60x60 km Airshed": "lucknow_airshed.geojson", 
            "Delhi 80x80 km Airshed": "delhi_airshed.geojson", 
            "West Bengal small Airshed": "wb_small_airshed.geojson", 
            }
# st.title("Brick Kilns Interactive Map")
st.markdown(
    f"""
    <h1 style="text-align: center;">Brick Kilns Interactive Map</h1>
    """,
    unsafe_allow_html=True,
)
region = st.selectbox("Select a region", list(file_map.keys()))

def style_function(feature):
    class_name = feature['properties']['class_name']
    if class_name == "Zigzag":
        return {'color': 'green', 'weight': 3, 'fillColor': 'green', 'fillOpacity': 0}
    elif class_name == "FCBK":
        return {'color': 'orange', 'weight': 3, 'fillColor': 'orange', 'fillOpacity': 0}
    elif class_name == "CFCBK":
        return {'color': 'red', 'weight': 3, 'fillColor': 'red', 'fillOpacity': 0}
    else:
        return {'color': 'black', 'weight': 3, 'fillColor': 'black', 'fillOpacity': 0}
    
gdf = gpd.read_file(join("labels", file_map[region]))
# fill the horizontal space with table
mapping = {"CFCBK": "Circular Fixed Chimney Bull's Trench Kiln (CFCBK)",
           "FCBK": "Fixed Chimney Bull's Trench Kiln (FCBK)",
           "Zigzag": "Zigzag Kiln"}
gdf['class_name'] = gdf['class_name'].apply(lambda x: mapping[x])
counts = gdf['class_name'].value_counts()
# add Total
counts['Total'] = counts.sum()
st.table(counts)

m = leafmap.Map()
m.add_basemap("SATELLITE")
legend_dict = {"CFCBK": "red", "FCBK": "orange", "Zigzag": "green", "Region of Interest": "blue"}
m.add_geojson(join("shapes", file_map[region]), layer_name="Region of Interest")
m.add_geojson(join("labels", file_map[region]), style_function=style_function, layer_name="Kilns")
m.add_legend(legend_dict=legend_dict, title="Brick Kilns")
m.to_streamlit()