【2027大数据毕设】基于大数据的全球各大首都城市每日天气数据可视化分析 (附源码资料)数据分析,可视化大屏 - climate_result = climate_pd_df
/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */
#content_views .toc,
/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */
#content_views.markdown_views > p:empty:has(+ .toc),
#content_views.markdown_views > .toc + p:empty,
/* 富文本旧版目录标记 */
#content_views.htmledit_views #main-toc,
#content_views.htmledit_views #hr-toc,
#content_views.htmledit_views p[id*="-toc"] {
display: none !important;
}
/* 目录去掉后,紧跟的首个标题不再多出一块上边距 */
#content_views.markdown_views > .toc + h1,
#content_views.markdown_views > .toc + h2,
#content_views.markdown_views > .toc + h3,
#content_views.markdown_views > .toc + h4,
#content_views.markdown_views > .toc + p:empty + h1,
#content_views.markdown_views > .toc + p:empty + h2,
#content_views.markdown_views > .toc + p:empty + h3,
#content_views.markdown_views > .toc + p:empty + h4 {
margin-top: 0 !important;
}
目录
基于大数据的全球各大首都城市每日天气数据可视化分析介绍基于大数据的全球各大首都城市每日天气数据可视化分析演示视频基于大数据的全球各大首都城市每日天气数据可视化分析演示图片基于大数据的全球各大首都城市每日天气数据可视化分析代码展示基于大数据的全球各大首都城市每日天气数据可视化分析文档展示
基于大数据的全球各大首都城市每日天气数据可视化分析介绍
本系统名为《基于大数据的全球各大首都城市每日天气数据可视化分析》,围绕全球多个首都城市的每日气象数据展开采集、清洗、存储、统计与可视化展示。系统以Hadoop与HDFS作为底层数据存储支撑,借助Spark与Spark SQL完成对大规模天气数据的分布式计算与聚合分析,并结合Pandas、NumPy对气温、空气质量、降水湿度、天气现象、风力气压等指标进行二次处理。后端分别支持Python+Django与Java+Spring Boot两套实现,数据库采用MySQL,用于存放用户信息、首都气象信息以及各类分析结果。前端基于Vue、ElementUI、Echarts、HTML、CSS、JavaScript与jQuery构建页面,通过图表、地图、趋势线等形式展示全球各大首都城市天气变化。系统功能涵盖系统首页、用户管理、首都气象信息、气温分布分析、空气质量分析、降水湿度分析、天气现象分析、风力气压分析、气候洞察分析以及大屏可视化,能够较完整地呈现从数据计算到可视化表达的流程。
基于大数据的全球各大首都城市每日天气数据可视化分析演示视频
演示视频
基于大数据的全球各大首都城市每日天气数据可视化分析演示图片
基于大数据的全球各大首都城市每日天气数据可视化分析代码展示
from pyspark.sql import SparkSession
from pyspark.sql.functions import col, avg, max, min, count, when, desc, sum as spark_sum
import pandas as pd
import numpy as np
spark = SparkSession.builder.appName("GlobalCapitalWeatherAnalysis").master("local[*]").config("spark.sql.shuffle.partitions", "4").enableHiveSupport().getOrCreate()
def temperature_distribution_analysis(spark, weather_df):
capital_temp_df = weather_df.select("capital_name", "country", "weather_date", "temperature", "temp_max", "temp_min")
clean_temp_df = capital_temp_df.filter(col("temperature").isNotNull()).filter(col("temp_max").isNotNull()).filter(col("temp_min").isNotNull())
clean_temp_df = clean_temp_df.withColumn("temp_range", col("temp_max") - col("temp_min"))
temp_avg_df = clean_temp_df.groupBy("capital_name", "country").agg(avg("temperature").alias("avg_temperature"), avg("temp_max").alias("avg_temp_max"), avg("temp_min").alias("avg_temp_min"), avg("temp_range").alias("avg_temp_range"), count("weather_date").alias("record_days"))
temp_avg_df = temp_avg_df.orderBy(desc("avg_temperature"))
temp_pd_df = temp_avg_df.toPandas()
temp_pd_df["avg_temperature"] = temp_pd_df["avg_temperature"].round(2)
temp_pd_df["avg_temp_range"] = temp_pd_df["avg_temp_range"].round(2)
temp_pd_df["temp_level"] = np.where(temp_pd_df["avg_temperature"] >= 30, "高温", np.where(temp_pd_df["avg_temperature"] >= 20, "温暖", np.where(temp_pd_df["avg_temperature"] >= 10, "温和", "偏冷")))
temp_result = temp_pd_df.to_dict(orient="records")
return temp_result 拼多多帮助力入口
def air_quality_analysis(spark, weather_df):
air_df = weather_df.select("capital_name", "country", "weather_date", "aqi", "pm25", "pm10", "air_quality_level")
clean_air_df = air_df.filter(col("aqi").isNotNull()).filter(col("pm25").isNotNull()).filter(col("pm10").isNotNull())
air_stat_df = clean_air_df.groupBy("capital_name", "country", "air_quality_level").agg(avg("aqi").alias("avg_aqi"), avg("pm25").alias("avg_pm25"), avg("pm10").alias("avg_pm10"), max("aqi").alias("max_aqi"), min("aqi").alias("min_aqi"), count("weather_date").alias("valid_days"))
air_stat_df = air_stat_df.orderBy("capital_name", desc("avg_aqi"))
air_pd_df = air_stat_df.toPandas()
air_pd_df["avg_aqi"] = air_pd_df["avg_aqi"].round(2)
air_pd_df["avg_pm25"] = air_pd_df["avg_pm25"].round(2)
air_pd_df["avg_pm10"] = air_pd_df["avg_pm10"].round(2)
air_pd_df["pollution_flag"] = np.where(air_pd_df["avg_aqi"] > 150, "污染偏重", np.where(air_pd_df["avg_aqi"] > 100, "轻度污染", "相对良好"))
air_result = air_pd_df.to_dict(orient="records")
return air_result
def climate_insight_analysis(spark, weather_df):
climate_df = weather_df.select("capital_name", "country", "weather_date", "temperature", "humidity", "precipitation", "wind_speed", "pressure", "weather_phase")
clean_climate_df = climate_df.filter(col("temperature").isNotNull()).filter(col("humidity").isNotNull()).filter(col("precipitation").isNotNull()).filter(col("wind_speed").isNotNull())
climate_group_df = clean_climate_df.groupBy("capital_name", "country", "weather_phase").agg(avg("temperature").alias("phase_avg_temp"), avg("humidity").alias("phase_avg_humidity"), spark_sum("precipitation").alias("phase_total_precipitation"), avg("wind_speed").alias("phase_avg_wind_speed"), avg("pressure").alias("phase_avg_pressure"), count("weather_date").alias("phase_days"))
climate_group_df = climate_group_df.filter(col("phase_days") >= 3)
climate_group_df = climate_group_df.orderBy("capital_name", desc("phase_total_precipitation"))
climate_pd_df = climate_group_df.toPandas()
climate_pd_df["phase_avg_temp"] = climate_pd_df["phase_avg_temp"].round(2)
climate_pd_df["phase_total_precipitation"] = climate_pd_df["phase_total_precipitation"].round(2)
climate_pd_df["climate_type"] = np.where(climate_pd_df["phase_avg_temp"] >= 25, "偏热气候", np.where(climate_pd_df["phase_avg_temp"] >= 15, "温和气候", "偏冷气候"))
climate_result = climate_pd_df.to_dict(orient="records")
return climate_result
基于大数据的全球各大首都城市每日天气数据可视化分析文档展示