Spaces:
Runtime error
Runtime error
Update pages/8_Rainfall.py
Browse files- pages/8_Rainfall.py +10 -3
pages/8_Rainfall.py
CHANGED
@@ -8,7 +8,7 @@ import folium
|
|
8 |
import base64
|
9 |
import pandas as pd
|
10 |
import numpy as np
|
11 |
-
from PIL import Image, ImageFilter
|
12 |
|
13 |
st.set_page_config(layout="wide", page_title="Rainfall Data Dashboard")
|
14 |
|
@@ -64,9 +64,16 @@ def filter_image_by_color(image, colors_to_extract_rgb):
|
|
64 |
def smooth_image(image):
|
65 |
return image.filter(ImageFilter.GaussianBlur(radius=3))
|
66 |
|
|
|
|
|
|
|
|
|
|
|
67 |
def create_map_with_radar_tile(image):
|
68 |
filtered_image = filter_image_by_color(image, COLORS_TO_EXTRACT_RGB)
|
69 |
smoothed_image = smooth_image(filtered_image)
|
|
|
|
|
70 |
m = folium.Map(location=[22.364, 114.148], zoom_start=10, min_zoom=10, max_zoom=19,
|
71 |
tiles='https://mapapi.geodata.gov.hk/gs/api/v1.0.0/xyz/imagery/wgs84/{z}/{x}/{y}.png',
|
72 |
attr="Map information from Lands Department", control_scale=True, name="Basemap")
|
@@ -76,12 +83,12 @@ def create_map_with_radar_tile(image):
|
|
76 |
overlay=True,
|
77 |
name="Labels"
|
78 |
).add_to(m)
|
79 |
-
img_url = f"data:image/png;base64,{image_to_base64(
|
80 |
folium.raster_layers.ImageOverlay(
|
81 |
image=img_url,
|
82 |
name="HKO Radar Image",
|
83 |
bounds=[[22.893, 113.538], [21.716, 115.362]],
|
84 |
-
opacity=0.
|
85 |
interactive=False,
|
86 |
cross_origin=False,
|
87 |
zindex=1,
|
|
|
8 |
import base64
|
9 |
import pandas as pd
|
10 |
import numpy as np
|
11 |
+
from PIL import Image, ImageFilter, ImageEnhance
|
12 |
|
13 |
st.set_page_config(layout="wide", page_title="Rainfall Data Dashboard")
|
14 |
|
|
|
64 |
def smooth_image(image):
|
65 |
return image.filter(ImageFilter.GaussianBlur(radius=3))
|
66 |
|
67 |
+
def enhance_contrast(image, factor=1.5):
|
68 |
+
enhancer = ImageEnhance.Contrast(image)
|
69 |
+
enhanced_image = enhancer.enhance(factor)
|
70 |
+
return enhanced_image
|
71 |
+
|
72 |
def create_map_with_radar_tile(image):
|
73 |
filtered_image = filter_image_by_color(image, COLORS_TO_EXTRACT_RGB)
|
74 |
smoothed_image = smooth_image(filtered_image)
|
75 |
+
enhanced_image = enhance_contrast(smoothed_image, factor=1.5)
|
76 |
+
|
77 |
m = folium.Map(location=[22.364, 114.148], zoom_start=10, min_zoom=10, max_zoom=19,
|
78 |
tiles='https://mapapi.geodata.gov.hk/gs/api/v1.0.0/xyz/imagery/wgs84/{z}/{x}/{y}.png',
|
79 |
attr="Map information from Lands Department", control_scale=True, name="Basemap")
|
|
|
83 |
overlay=True,
|
84 |
name="Labels"
|
85 |
).add_to(m)
|
86 |
+
img_url = f"data:image/png;base64,{image_to_base64(enhanced_image)}"
|
87 |
folium.raster_layers.ImageOverlay(
|
88 |
image=img_url,
|
89 |
name="HKO Radar Image",
|
90 |
bounds=[[22.893, 113.538], [21.716, 115.362]],
|
91 |
+
opacity=0.95,
|
92 |
interactive=False,
|
93 |
cross_origin=False,
|
94 |
zindex=1,
|