Rain cloud data was implemented semi-successfully on the map. The map was not visible

problem is Floating a map (successful), floating rain cloud data on the map (successful), but the visualized rain cloud data obscures the map.

this code is python

What I tried

Implement a method to set the transparency of the map to 50%
Overlay a semi-transparent map on top of the map using the Canvas widget
Use the 
#update_map_overlay 
method to capture a map image, dim it, set transparency, and display it 
on the canvas.
This will make the precipitation overlay and map visible together. I am using ImageGrab to capture 
images of a map.
But I only see a white screen

A different approach was used

Instead of adding a translucent rainfall layer on top of the map,
I directly drew an image with the transparency of the map adjusted.
To achieve this, we used Pillow to make the image transparent and drew it on #Tkinter's Canvas.

But still white screen

A different approach was used

To implement a way to display map and radar overlay together without using Canvas.
, The approach was to set the radar tile of tkintermapview and adjust the transparency.
Although tkintermapview itself does not have an option to adjust the transparency of radar tiles,
Instead of adjusting the transparency of map tiles, you can change the background of the entire UI,
including the map.

But still white screen

use a different approach

To display the map and radar overlay together, we will use #Basemap (mpl_toolkits.basemap) 
and Matplotlib to draw the map and display it in #Tkinter.

Bug
use a different approach
Implement this by drawing a map using #cartopy and #matplotlib and integrating it with #Tkinter.

failure

I tried various methods other than this, but they all failed due to my lack of skills.

this is code

import tkinter as tk
from tkinter import ttk
from PIL import Image, ImageTk, ImageDraw
import requests
import tkintermapview
import math

class WeatherRadar:
    def __init__(self, root):
        self.root = root
        self.root.title("WRS")
        self.root.state('zoomed')

        self.create_top_section()
        self.create_bottom_section()
        self.overlay_global_rainfall()  #비구름 데이터

    def create_top_section(self):
        top_frame = ttk.Frame(self.root)
        top_frame.pack(side=tk.TOP, fill=tk.X, expand=False)

        # 날씨 정보 표시
        self.track_temp_label = ttk.Label(top_frame, text="Track Temp: N/A")
        self.track_temp_label.grid(row=1, column=0, padx=10, pady=10)
        self.humidity_label = ttk.Label(top_frame, text="Humidity: N/A")
        self.humidity_label.grid(row=1, column=1, padx=10, pady=10)
        self.air_temp_label = ttk.Label(top_frame, text="Air Temp: N/A")
        self.air_temp_label.grid(row=1, column=2, padx=10, pady=10)
        self.wind_speed_label = ttk.Label(top_frame, text="Wind Speed: N/A")
        self.wind_speed_label.grid(row=1, column=3, padx=10, pady=10)

        wind_frame = ttk.Frame(top_frame)
        wind_frame.grid(row=1, column=4, padx=10, pady=10)
        self.wind_direction_label = ttk.Label(wind_frame, text="Wind Direction: N/A")
        self.wind_direction_label.pack(side=tk.LEFT)

        self.wind_direction_canvas = tk.Canvas(wind_frame, width=50, height=50)
        self.wind_direction_canvas.pack(side=tk.LEFT)

        # Rain forecast
        self.rain_forecast_entry_eta_label = ttk.Label(top_frame, text="Rain ETA: N/A")
        self.rain_forecast_entry_eta_label.grid(row=2, column=0, padx=10, pady=10)
        self.rain_forecast_exit_eta_label = ttk.Label(top_frame, text="Rain Exit ETA: N/A")
        self.rain_forecast_exit_eta_label.grid(row=2, column=1, padx=10, pady=10)
        self.rain_intensity_label = ttk.Label(top_frame, text="Rain Intensity: N/A mm/h")
        self.rain_intensity_label.grid(row=2, column=2, padx=10, pady=10)

    def create_bottom_section(self):
        bottom_frame = ttk.Frame(self.root)
        bottom_frame.pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)

        # 지도 표시
        self.map_widget = tkintermapview.TkinterMapView(bottom_frame, corner_radius=0)
        self.map_widget.pack(fill="both", expand=True)
        self.map_widget.set_zoom(16)  # 초기 줌 레벨을 16으로 설정하여 더 확대된 상태로 시작

    def fetch_weather_data(self, lat, lon):
        api_key = " api key "
        url = f"http://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={api_key}&units=metric"
        response = requests.get(url)
        if response.status_code == 200:
            data = response.json()
            track_temp = data['main']['temp']
            humidity = data['main']['humidity']
            air_temp = data['main']['feels_like']
            wind_speed = data['wind']['speed']
            wind_deg = data['wind']['deg']

            self.track_temp_label.config(text=f"Track Temp: {track_temp}°C")
            self.humidity_label.config(text=f"Humidity: {humidity}%")
            self.air_temp_label.config(text=f"Air Temp: {air_temp}°C")
            self.wind_speed_label.config(text=f"Wind Speed: {wind_speed} m/s")
            self.wind_direction_label.config(text=f"Wind Direction: {wind_deg}°")

            self.update_wind_direction_canvas(wind_deg)

            # For now, setting rain forecast to N/A
            self.rain_forecast_entry_eta_label.config(text="Rain ETA: N/A")
            self.rain_forecast_exit_eta_label.config(text="Rain Exit ETA: N/A")
            self.rain_intensity_label.config(text="Rain Intensity: N/A mm/h")
        else:
            print("Failed to fetch weather data")

    def overlay_global_rainfall(self):
        # OpenWeatherMap 레이더 타일 URL 패턴
        radar_tile_url = "https://tile.openweathermap.org/map/precipitation_new/{z}/{x}/{y}.png?appid="
        self.map_widget.set_tile_server(radar_tile_url)

    def update_wind_direction_canvas(self, wind_deg):
        self.wind_direction_canvas.delete("all")
        center_x, center_y = 25, 25
        length = 20
        angle_rad = math.radians(wind_deg)

        end_x = center_x + length * math.cos(angle_rad)
        end_y = center_y - length * math.sin(angle_rad)

        self.wind_direction_canvas.create_line(center_x, center_y, end_x, end_y, arrow=tk.LAST, fill="blue", width=2)

       

if __name__ == "__main__":
    root = tk.Tk()
    app = WeatherRadar(root)
    root.mainloop()



New contributor

4527PENK is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật