ChatGPT 为我制作了一张地图

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

640?wx_fmt=gif  

watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQxNTcwNjU4,size_16,color_FFFFFF,t_70

有人说一个人从1岁活到80岁很平凡但如果从80岁倒着活那么一半以上的人都可能不凡。

生活没有捷径我们踩过的坑都成为了生活的经验这些经验越早知道你要走的弯路就会越少。 


今天在刷视频的时候看到了我订阅的Youtube博主更新了感觉内容蛮有用的就分享给大家

原视频链接如下打开需要魔法

https://www.youtube.com/watch?v=iNHQgLw7qZc

数据说明

本数据采用的是中国的机场数据数据来源ourairports该数据详细介绍可参考下列内容

https://mp.weixin.qq.com/s/YFEEphaNWHhFXhjzGe89qw

这是该网站上内嵌的web机场地图正在本期教程中我们将让ChatGPT来制作这样一份地图

 

数据比较杂乱注意记住这三列就可以

代码编写

交互式地图绘制

作为一个对话型AI当然需要告诉他我使用什么数据什么平台什么编程语言完成地图让我们见识一下ChatGPT的能力吧

 

修改一下文件路径然后运行程序

import pandas as pd
import geopandas as gpd
from folium import Map, Marker

# Read the CSV file into a DataFrame
df = pd.read_csv(r"C:\Users\zheyu\Desktop\cn-airports.csv")

# Convert the DataFrame to a GeoDataFrame
gdf = gpd.GeoDataFrame(
    df, 
    geometry=gpd.points_from_xy(df.longitude_deg, df.latitude_deg)
)

# Create an instance of the Folium Map class
m = Map(location=[df.latitude_deg.mean(), df.longitude_deg.mean()])

# Iterate over the rows of the GeoDataFrame
for i, row in gdf.iterrows():
    Marker(location=[row.latitude_deg, row.longitude_deg], popup=row.name).add_to(m)

# Save the map to an HTML file
m.save("map.html")

然后在桌面就会生成一个map.html,你可以使用任何网络浏览器打开

显示的数据多是因为包含了直升机机场

 

筛选需要的数据

在数据中type列是机场属性接下来就让ChatGPT教我如何显示筛选出的大型机场吧

 

这是ChatGPT修改后的代码

import pandas as pd
import geopandas as gpd
from folium import Map, Marker

# Read the CSV file into a DataFrame
df = pd.read_csv(r"C:\Users\zheyu\Desktop\cn-airports.csv")

# Filter the DataFrame to only include rows with "type" value "large_airport"
df = df[df.type == "large_airport"]

# Convert the DataFrame to a GeoDataFrame
gdf = gpd.GeoDataFrame(
    df, 
    geometry=gpd.points_from_xy(df.longitude_deg, df.latitude_deg)
)

# Create an instance of the Folium Map class
m = Map(location=[gdf.latitude_deg.mean(), gdf.longitude_deg.mean()])

# Iterate over the rows of the filtered GeoDataFrame
for i, row in gdf.iterrows():
    Marker(location=[row.latitude_deg, row.longitude_deg], popup=row.name).add_to(m)

# Save the map to an HTML file
m.save("map.html")

默认使用的是osm作为背景

 

修改web地图图层

ChatGPT切换成卫星影像

ChatGPT具有上下文多轮会话能力这太神奇了

 

生成的代码如下

import pandas as pd
import geopandas as gpd
from folium import Map, Marker

# Read the CSV file into a DataFrame
df = pd.read_csv(r"C:\Users\zheyu\Desktop\cn-airports.csv")

# Filter the DataFrame to only include rows with "type" value "large_airport"
df = df[df.type == "large_airport"]

# Convert the DataFrame to a GeoDataFrame
gdf = gpd.GeoDataFrame(
    df, 
    geometry=gpd.points_from_xy(df.longitude_deg, df.latitude_deg)
)

# Create an instance of the Folium Map class
m = Map(location=[gdf.latitude_deg.mean(), gdf.longitude_deg.mean()], tiles='https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', attr='Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community')

# Iterate over the rows of the filtered GeoDataFrame
for i, row in gdf.iterrows():
    Marker(location=[row.latitude_deg, row.longitude_deg], popup=row.name).add_to(m)

# Save the map to an HTML file
m.save("map.html")

结语

 

ChatGPT的功能不仅仅是制作这种简单的交互式地图他在很多领域有着非常大的应用我们行业内就有大佬用它写标书写规划大纲他很大程度上减轻了我们的重复劳动。

在遥感和GIS领域我看到他巨大的潜力特别是作为编写代码修改BUG的工具方面他会给我们提供非常有用的指导在未来 的地理空间分析学习工程中我将尝试把ChatGPT带给你们展现出在AI帮助下我们的工作将会变得更加轻松

 这些程序员职场“潜规则”让你少走5年弯路_【官方推荐】唐城的博客-CSDN博客


   Ã¥Â®Â«Ã¥Â´Ã©ÂªÃ©Â¾Ã§Â«Ã¨Â¡Â¨Ã¦Ã¥|é¾ç«gifå¾è¡¨æåä¸è½½å¾ç一边赶路一边寻找出路希望大家在每个幸福的日子里都能快乐前行。


阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6
标签: ChatGPT