Arctern pandas入门-前后端渲染

    Arctern基于开源大数据生态,构建灵活、强大、高性能的时空数据分析平台,帮助用户应对5G/IoT带来的新型数据挑战,加速时空数据的处理、分析、模型预测与呈现。本文中将会介绍Arctern pandas安装和简单使用

Arctern安装

    参照官网安装教程,。激活arctern环境,进入python,打印arctern版本就可以查看是否安装成功

Arctern后端渲染展示

    后端展示基本是参照官网安装教程,但是有两个地方要注意:

一:以散点图为例,原来的给出来的代码会在我的电脑上一直不能加载出来图片,我们需要自己修改下contextily选择的底图如contextily.providers.CartoDB.Voyager,其他的可视化案例同样需要注意;

二:icon展示图,原文中的图标地址已经不存在,可使用下面地址https://user-gold-cdn.xitu.io/2020/6/21/172d46470736bad7?w=19&h=38&f=png&s=674保存下来图标或者用任意图标代替。
下面是示例代码和点图、带权点图、热力图、轮廓图、图标图、渔网图效果图

import pandas as pd
import random
import arctern
from arctern.util import save_png, vega
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import contextily as cx

def gen_data(num_rows, bbox):
    pickup_longitude = [(bbox[2]-bbox[0])*random.random()+bbox[0] for i in range(num_rows)]
    pickup_latitude = [(bbox[3]-bbox[1])*random.random()+bbox[1] for i in range(num_rows)]
    fare_amount = [100*random.random() for i in range(num_rows)]
    tip_amount = [fare*(random.random()*0.05+0.15) for fare in fare_amount]
    total_amount = [fare_amount[i]+tip_amount[i] for i in range(num_rows)]
    return pd.DataFrame({"pickup_longitude":pickup_longitude,
                         "pickup_latitude":pickup_latitude,
                         "fare_amount":fare_amount,
                         "total_amount":total_amount})

num_rows=200
bbox=[-73.991504, 40.770759, -73.945155, 40.783434]
df=gen_data(num_rows,bbox)
fig, ax = plt.subplots(figsize=(10, 6), dpi=200)

arctern.plot.pointmap(ax,arctern.GeoSeries.point(df.pickup_longitude,df.pickup_latitude),bbox,point_size=6,point_color="#2DEF4A",opacity=1,coordinate_system="EPSG:4326",source=cx.providers.CartoDB.Voyager)






Arctern前端渲染展示

参考资料:

https://arctern.io/docs/versions/v0.2.x/development-doc-cn/html/quick_start/standalone_installation.html

https://blog.csdn.net/xiaocai_233/ticle/details/104751847

https://github.com/geopandas/contextily/blob/master/tests/test_ctx.py

https://github.com/geopandas/contextily/blob/e0bb25741f9448c5b6b0e54d403b0d03d9244abd/contextily/_providers.py

https://arctern.io/docs/versions/v0.2.x/development-doc-cn/html/api_reference/plot/api/arctern.plot.pointmap.html#arctern.plot.pointmap

https://contextily.readthedocs.io/en/latest/intro_guide.html?highlight=providers openstreetmap mapnik

https://arctern.io/docs/versions/v0.2.x/development-doc-cn/html/feature_description/visualization/backend_visualization/arctern_plot.html

posted @ 2020-06-22 22:14  polong  阅读(459)  评论(0编辑  收藏  举报