第19章 地理空间数据地图可视化指南
第19章 Maps(地图)
如果你的数据集包含地理空间数据,可以在地图上进行可视化。 Plotly Studio 支持以下几种地图类型:
散点地图(scatter map):将每一行数据按经纬度列的坐标显示为一个标记点 密度热力图(density heatmap):对每个点做平滑处理并赋予影响半径,展示数据密集程度 分级统计图(choropleth map):根据数据值为地理区域(国家、州、县)着色
你可以自定义地图样式、缩放级别等视觉属性。
Scatter map(散点地图)
将每一行数据按经纬度列的坐标显示为一个标记点。
使用
以下示例结合 Montreal Open Data Portal 的自行车流量计数器数据,使用了这种提示词结构: Create a scatter map using latitude and longitude.
Density heatmap(密度热力图)
使用密度热力图展示地理区域上的点密集程度,每个点都会做平滑处理并赋予影响半径。
使用
以下示例结合 Plotly 公共数据集仓库的地震数据,使用了这种提示词结构来展示地震活动区域: Create a density heatmap map using latitude and longitude. Use magnitude for intensity.
Choropleth map(分级统计图)
根据数据值为国家、州或县等地理区域着色。分级统计图需要位置标识符(如州名、国家代码或 FIPS 代码),且必须与预定义的地理边界匹配。
使用
以下示例结合 Plotly 公共数据集仓库中的美国县级失业率数据,使用了这种提示词结构。FIPS 代码唯一标识每个美国县,使地图能够按失业率为各县着色。scope 设为 USA 以聚焦美国,Viridis 配色方案提供清晰的视觉区分,颜色范围设为 0 到 12: Create a choropleth map using county FIPS code for locations, colored by unemployment rate. Set scope to USA. Use Viridis color scale. Set color range from 0 to 12.
地图样式自定义
三种地图类型(散点地图、密度热力图、分级统计图)都支持自定义地图样式。可以根据可视化需求切换地图样式,从基础样式到卫星影像均可。
使用
以下是各种可用地图样式的提示词: BasicDarkLightOpen Street MapSatelliteSatellite StreetsCarto Voyager
Create a scatter map using latitude and longitude. Use basic map style.
Create a scatter map using latitude and longitude. Use dark map style.
Create a scatter map using latitude and longitude. Use light map style.
Create a scatter map using latitude and longitude. Use open-street-map map style.
Create a scatter map using latitude and longitude. Use satellite map style.
Create a scatter map using latitude and longitude. Use satellite-streets map style.
Create a scatter map using latitude and longitude. Use carto-voyager map style.
交互控件
为散点地图添加下拉菜单等控件,使其支持交互。控件让用户可以动态筛选和探索数据。 以下示例结合 Montreal Open Data Portal 的自行车流量计数器数据,使用了这种提示词结构: Create a scatter map using latitude and longitude. Size markers by total passages, aggregated by location and date. Add a date range picker to filter by date range - Default last 30 days.
提示词关键词参考
在提示词中使用以下关键词和短语来自定义地图。
Chart(图表)
以下是创建和自定义图表的关键词建议: Scatter MapDensity HeatmapChoropleth Map
Keyword/Phrase Description Example
Latitude 包含纬度坐标的列 latitude
Longitude 包含经度坐标的列 longitude
Color 按不同分组或数值为标记着色 color by day of week
Size 根据某个值调整标记大小 size by total passages
Keyword/Phrase Description Example
Latitude 包含纬度坐标的列 latitude
Longitude 包含经度坐标的列 longitude
Z 控制热力图的强度/颜色 use magnitude for intensity
Keyword/Phrase Description Example
Locations 地理标识符(州名、国家代码、FIPS 代码) county FIPS code
Color 按不同分组或数值为区域着色 colored by unemployment rate
Data(数据)
在提示词中指定数据处理指令,可在可视化之前对数据进行转换、筛选或聚合。 Sum passages by location and date. Filter to dates after 2024-01-01.
以下是一些关键词建议:
Keyword/Phrase Description Example
Aggregation 指定数据聚合方式 sum passages by location
Computed field 基于现有数据创建新的计算字段 calculate weekday based on date
Filter 按条件筛选数据 filter to dates after 2024-01-01
Options(选项)
在提示词中指定选项,可添加交互控件,让用户无需重新生成图表就能动态筛选、转换和查看数据。 Add a dropdown to select location type (All, Major, Minor) - Default All. Add a date range picker to filter by date range - Default last 30 days.
以下是一些关键词建议。完整控件类型列表和更多示例请参阅 App Controls。
Keyword/Phrase Description Example
Dropdown 添加下拉菜单按类别筛选 Add a dropdown to select location type (All, Major, Minor) - Default All
Date range picker 添加日期范围选择器 Add a date range picker to filter by date range - Default last 30 days
Chart styles(图表样式)
在提示词中指定图表样式,控制地图的视觉外观和格式。 Scatter MapDensity HeatmapChoropleth Map
Use dark map style. Set zoom level to 12. Set marker opacity to 0.7.
以下是一些关键词建议:
Keyword/Phrase Description Example
Map style 从地图瓦片样式中选择:basic、dark、light、open-street-map、satellite、satellite-streets、carto-voyager Use satellite-streets map style
Zoom level 设置初始缩放级别(1-20) Set zoom level to 12
Center map 设置地图中心点 Center map on Montreal
Marker size 为所有点设置固定标记大小 Set marker size to 10
Maximum marker size 使用 Size 映射时设置最大标记大小(默认 20) Set maximum marker size to 50
Marker opacity 控制标记透明度 Set marker opacity to 0.7
Show labels 基于某个数据字段在标记上显示文本标签 Show labels from counter name
Custom colors 为类别或渐变指定精确颜色 Use custom colors: #FF5733, #33FF57, #3357FF
Color scale 指定连续颜色映射的色标。参见内置色标 Use Viridis color scale
Hover text 鼠标悬停在标记上时显示的内容 Show counter name on hover
Use dark map style. Set radius to 10 pixels. Set opacity to 0.5.
以下是一些关键词建议:
Keyword/Phrase Description Example
Map style 从地图瓦片样式中选择:basic、dark、light、open-street-map、satellite、satellite-streets、carto-voyager Use dark map style
Zoom level 设置初始缩放级别(1-20) Set zoom level to 2
Center map 设置地图中心点 Center map on Pacific Ocean
Radius 设置平滑半径(像素) Set radius to 10 pixels
Opacity 设置热力图图层透明度(0-1) Set opacity to 0.5
Custom colors 为渐变指定精确颜色 Use custom colors: #FF5733, #33FF57, #3357FF
Color scale 指定连续颜色映射的色标。参见内置色标 Use Hot color scale
Color range 设置颜色缩放的最小值和最大值 Set color range from 0 to 8
Hover text 鼠标悬停在热力图上时显示的内容 Show location name on hover
Use light map style. Use Viridis color scale. Set color range from 0 to 12.
以下是一些关键词建议:
Keyword/Phrase Description Example
Map style 从地图瓦片样式中选择:basic、dark、light、open-street-map、satellite、satellite-streets、carto-voyager Use light map style
Zoom level 设置初始缩放级别(1-20) Set zoom level to 4
Center map 设置地图中心点 Center map on USA
Custom colors 为类别或渐变指定精确颜色 Use custom colors: #FF5733, #33FF57, #3357FF
Color scale 指定连续颜色映射的色标。参见内置色标 Use Viridis color scale
Color range 设置颜色缩放的最小值和最大值 Set color range from 0 to 12
Hover text 鼠标悬停在区域上时显示的内容 Show county name on hover