为情节互动地图提取经度和纬度

问题描述 投票:0回答:1

我在 youtube 上搜索了有关使用经纬度进行创作的视频 交互式地图。 我有一个关于地震的数据集,其中经度和纬度都是浮动的: Significant_Earthquakes_1900_2023 我尝试使用此代码失败:

import csv
filename = '/kaggle/input/significant-earthquake-dataset-1900-2023/Significant Earthquake Dataset 1900-2023.csv'
keys = ('Latitude','Longitude')
records = []
with open(filename,'r') as csvfile:
    reader = csv.DictReader(csvfile)
    for row in reader:
        records.append({keys:row[key] for key
                       in keys})
records[0]
record = records[0]
coords = record['Latitude','Longitude'].split("(")[-1].split(")")[0]
coords

I got eventually this output:
{('Latitude', 'Longitude'): '132.0763'}
132.0763

如何使用 geojson、csv 或 folium 为 plotly 创建可视化? 谢谢

python plotly data-science geojson
1个回答
0
投票

看看下面的代码是否解决了你的问题:

import csv
filename = 'Significant Earthquake Dataset 1900-2023.csv'
keys = ('Latitude','Longitude')
records = []
with open(filename,'r', encoding='utf-8') as csvfile:
    reader = csv.DictReader(csvfile)
    for row in reader:
        records.append({key: row[key] for key in keys})
records

输出:

我从kagle下载了文件。我放了编码,因为它导致了错误。而不是循环内的键,我用键替换了。

© www.soinside.com 2019 - 2024. All rights reserved.