如何使用OpenStreetMap在地图上绘制gps数据(csv)

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

首先抱歉我的英语。我正在研究我大学生涯的最后一个项目。我有数百名学生上学时的GPS数据(纬度和经度),我必须在地图上表示这些点,以便能够看到轨迹并了解GPS的准确性并清理一些数据。

我的导师告诉我使用OpenStreetMap在地图上提取这些数据。

我已经研究了很多天,我已经设法在学校所在地区的地图上绘制轨迹,但想法是放大学校所在的区域并精确地查看点和街道。我想我必须从OpenStreetMap添加一些图层,但我不知道该怎么做。

我告诉你我用过的代码:


import osmnx as ox
import networkx as nx
import geopandas as gpd
import matplotlib.pyplot as plt
import pandas as pd
from shapely.geometry import Point, Polygon
from time import time

%matplotlib inline


place_name='Sants-Montjuïc, Barcelona, Spain' #district of school
graph=ox.graph_from_place(place_name)  
type(graph)


nodes, edges = ox.graph_to_gdfs(graph)   
nodes.head()
edges.head()
type(edges)


fig, ax = plt.subplots(figsize=(15,15)) 
edges.plot(ax=ax, linewidth=1, edgecolor='#BC8F8F')  


df=pd.read_csv('C:\\Users\\1-MON.csv')  #csv file with the data
crs={'init': 'epsg:4326'}
df.head()

geometry=[Point(xy) for xy in zip( df["longitude"], df["latitude"])]

geo_df=gpd.GeoDataFrame(df, crs=crs, geometry=geometry)   
geo_df.head()
geo_df.plot(ax=ax, marker='o',markersize=2, color="blue")

enter image description here

正如我所说,我想要一张地图,清楚地展示学校所在地区的街道,而不是整个地区。并在其上绘制gps数据。

我怎样才能实现它?谢谢!!

python openstreetmap geopy osmnx
1个回答
0
投票

如果要使用较小的地图,则必须通过边界框指定所需的区域。使用边界框的坐标,您可以从osm查询数据。通过查询bbox中的所有数据,您只需绘制对象的几何图形,然后添加自己的数据点

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