高德地图上那种路况堵得发黑是如何实现的?

本文介绍如何利用Arctern和上海渣土车的完整轨迹数据,分析道路拥堵情况,模拟类似高德地图的实时路况。通过数据加载、车辆轨迹分析、路网与轨迹展示、道路权重分析等步骤,揭示繁忙道路并展示其在地图上的分布。
摘要由CSDN通过智能技术生成

原文地址: sh truck bootcamp


前一篇文章中,我们简单的介绍了使用 Arctern分析纽约出租车的的数据。在那个例子中,出租车的数据只有上车点和下车点的数据,没有完整的轨迹数据,所以整个分析显得有点意犹未尽。

在这篇文章中,我们使用上海市的渣土车数据,该数据包含完整的轨迹数据,所有我们可以实现类似高德地图的功能,分析在特定时间段内哪些道路比较拥堵。
废话不多说,以下为原文。


环境准备

  • 安装 Arctern
  • 安装 Jupyter

    在上一步中的 arctern_env 环境中执行以下命令安装 Jupyter Notebook:

    $ conda install -c conda-forge notebook
    
  • 安装依赖库

    arctern_env 环境中执行以下命令安装相关依赖库:

    $ pip install keplergl matplotlib
    

下载数据

我们需要下载 200 多万条上海渣土车数据和上海市的地形数据图数据,默认将其下载至 /tmp 下:

$ cd /tmp
# 下载并解压上海渣土车数据
$ wget https://github.com/arctern-io/arctern-bootcamp/raw/master/shtruck/file/20181016.zip
$ unzip 20181016.zip
# 下载上海市的地形数据图
$ wget https://github.com/arctern-io/arctern-bootcamp/raw/master/shtruck/file/sh_roads.csv

运行 jupyter-notebook

下载 arctern_shtruck_bootcamp.ipynb 文件,在 arctern_env 环境中运行 jupyter notebook:

$ wget https://raw.githubusercontent.com/zilliztech/arctern-bootcamp/master/shtruck/arctern_shtruck_bootcamp.ipynb
# 运行 jupyter notebook
$ jupyter notebook

在 jupyter 网页中打开 arctern_shtruck_bootcamp.ipynb 文件,就可以开始运行代码了。

上海渣土车数据分析示例

1. 数据加载

加载上海市渣土车运行轨迹数据,原数据共 8 列,此处只读取本文分析所需要的 4 列:车牌号、时间、经度、维度。

import pandas as pd
import arctern
from arctern import GeoSeries

sh_columns=[
    ("plate_number","string"),
    ("pos_time","string"),
    ("pos_longitude","double"),
    ("pos_latitude","double"),
    ("pos_direction0","double"),
    ("pos_direction1","double"),
    ("pos_direction2","double"),
    ("pos_direction3","double")
]

sh_select_columns={
   
                   "plate_number",
                   "pos_time",
                   "pos_longitude",
                   "pos_latitude"
                  }

sh_schema={
   }
sh_use_cols=[]
sh_names=[]
for idx in range(len(sh_columns)):
    if sh_columns[idx][0] in sh_select_columns:
        sh_schema[sh_columns[idx][0]] = sh_columns[id
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值