赞
踩
在水环境实际分析中,往往要对采样数据进行可视化,方便分析判断。
现在有了chatgpt 可以更快更好的完成这一任务。
监测数据如下:
将数据直接发给chatgpt
提出需求,越精细越好。
他回答并返回结果:
- import pandas as pd
- import folium
- from folium.plugins import HeatMap
-
- # 创建坐标轴数据表格
- data = {"Name": ["YuJianTan", "TiaoDengZi", "XiangJiaTan", "WuLiQiao", "CiBa", "CiBaAuto", "LiJiQiao", "BaoShan", "ZhuYangXi", "LinJiangHe"],
- "Lat": [29.22159555, 29.19100425, 29.15961747, 29.13475581, 29.10543124, 29.1133509, 29.11030903, 29.08354826, 29.06511879, 29.25768],
- "Lon": [105.9492021, 105.9590533, 105.9415321, 105.928865, 105.940524, 105.9277196, 105.9577255, 105.949189, 105.9416183, 105.94348],
- "Fluoride": [0.751, 0.701, 0.816, 0.848, 0.832, 0.856, 0.757, 0.747, 0.766, 0.583]}
- df = pd.DataFrame(data)
-
- # 绘制热力图
- m = folium.Map(location=[df["Lat"].mean(), df["Lon"].mean()], zoom_start=13)
- heat_data = [[row["Lat"], row["Lon"], row["Fluoride"]] for index, row in df.iterrows()]
- HeatMap(heat_data).add_to(m)
-
- # 绘制平滑曲线
- locs = df[["Lat", "Lon"]].values.tolist()
- fluorides = df["Fluoride"].values.tolist()
-
- from scipy.interpolate import interp1d
- import numpy as np
-
- x_min = min(df["Lat"].min(), df["Lon"].min())
- x_max = max(df["Lat"].max(), df["Lon"].max())
- f = interp1d(np.linspace(x_min, x_max, len(fluorides)), fluorides, kind="cubic")
- xs = np.linspace(x_min, x_max, 100)
- ys = f(xs)
- coords = [[y, x] for y, x in zip(xs, ys)]
-
- folium.PolyLine(coords, color="blue", weight=4).add_to(m)
-
- m
虽然结果并不完美,但可以继续对其完善。整体体验下来,非常流畅且节约大量时间。
以后再进一步总结将大大提高工作效率。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。