ChatGPT 为我制作了一张地图

1年前未命名32
ChatGPT 为我制作了一张地图 唐 城 于2023-02-06 18:05:55发布 780 收藏 6 分类专栏: 唐城 | 奇妙之旅-GIS 唐城 | 未来已来 文章标签: chatgpt 唐城 | 奇妙之旅-GIS 同时被 2 个专栏收录 73 篇文章 14 订阅 订阅专栏 唐城 | 未来已来 21 篇文章 2 订阅 订阅专栏

  

有人说:一个人从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博客


   一边赶路,一边寻找出路,希望大家在每个幸福的日子里,都能快乐前行。


标签: [db:标签TAG]

相关文章

HTTP安全与HTTPS协议

HTTP安全与HTTPS协议...

一口吃不成ChatGPT,复旦版MOSS服务器被挤崩后续

一口吃不成ChatGPT,复旦版MOSS服务器被挤崩后续...

有了独自开,一个人就是一个团队

有了独自开,一个人就是一个团队...

网易二面:CPU狂飙900%,该怎么处理?

网易二面:CPU狂飙900%,该怎么处理?...

Redis 被问麻了...

Redis 被问麻了......

【GPT-4】GPT-4 相关内容总结

【GPT-4】GPT-4 相关内容总结...