M04-西安市滴滴打车数据-Bokeh

import warnings
warnings.filterwarnings('ignore')

import os

import numpy as np
from scipy.stats import norm
import pandas as pd

import seaborn as sns
import matplotlib.pyplot as plt
get_ipython().run_line_magic('matplotlib', 'inline')

plt.rcParams['font.sans-serif'] = ['SimHei']
plt.rcParams['axes.unicode_minus'] = False 

import cartopy.crs as ccrs
import geopandas as gpd
import cartopy.io.shapereader as shpreader
from shapely.geometry import Polygon
from matplotlib.patches import Polygon as mpl_polygon

西安滴滴打车数据

import folium
# 数据点不要太多
df_gao = pd.read_csv('data/出租车订单数据一周_split_1.csv') .head(1000)

folium与bokeh结合

import folium
from folium.plugins import HeatMap
from bokeh.embed import components
from bokeh.layouts import column
from bokeh.models import Div
from bokeh.io import output_notebook, show
output_notebook() 
Loading BokehJS ...
# 创建Folium地图对象
m = folium.Map([34.34, 108.94],
               tiles='http://webrd02.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=7&x={x}&y={y}&z={z}',
               attr='高德-常规图',
               zoom_start=10)
# 假设坐标点数据存储在一个名为locations的列表中
locations = []
for index, row in df_gao.iterrows():
    locations.append([row['on_lat'], row['on_lon']])
# 使用HeatMap插件生成热力图
heat_map = HeatMap(locations)
# 将热力图添加到地图上
heat_map.add_to(m)
# 将Folium地图转换为HTML字符串
html_map = m.get_root().render()
# 创建一个Bokeh的Div组件,并将Folium地图的HTML字符串作为内容
div = Div(text=html_map, width=800, height=600)
# 创建Bokeh布局,将Folium地图的Div组件添加到布局中
layout = column(div)
# 在Jupyter Notebook中显示布局
show(layout)
m
Make this Notebook Trusted to load map: File -> Trust Notebook

</head>
<body>

        &lt;div class=&quot;folium-map&quot; id=&quot;map_aef33a1e49a07948a240f2698fab96ba&quot; &gt;&lt;/div&gt;

</body>
<script>

        var map_aef33a1e49a07948a240f2698fab96ba = L.map(
            &quot;map_aef33a1e49a07948a240f2698fab96ba&quot;,
            {
                center: [34.34, 108.94],
                crs: L.CRS.EPSG3857,
                zoom: 10,
                zoomControl: true,
                preferCanvas: false,
            }
        );





        var tile_layer_d49a6a09a9249b0ac3d1872719fa91af = L.tileLayer(
            &quot;http://webrd01.is.autonavi.com/appmaptile?lang=zh_cn\u0026size=1\u0026scale=1\u0026style=7\u0026x={x}\u0026y={y}\u0026z={z}&quot;,
            {&quot;attribution&quot;: &quot;\u9ad8\u5fb7-\u5e38\u89c4\u56fe&quot;, &quot;detectRetina&quot;: false, &quot;maxNativeZoom&quot;: 18, &quot;maxZoom&quot;: 18, &quot;minZoom&quot;: 0, &quot;noWrap&quot;: false, &quot;opacity&quot;: 1, &quot;subdomains&quot;: &quot;abc&quot;, &quot;tms&quot;: false}
        );


        tile_layer_d49a6a09a9249b0ac3d1872719fa91af.addTo(map_aef33a1e49a07948a240f2698fab96ba);


        var heat_map_cb6892288324792f5f8c8d124591c195 = L.heatLayer(
            [[34.284082, 108.843652], [34.26169, 108.92121], [34.28814, 108.86915], [34.307332, 108.83724], [34.27439, 108.86726], [34.26088, 108.867202], [34.268615, 108.890042], [34.250115, 108.87195], [34.237095, 108.87264], [34.19957, 108.94338], [34.194627, 108.969077], [34.245207, 108.92764], [34.24293, 108.962015], [34.241685, 108.949167], [34.261345, 108.965725], [34.246865, 108.958685], [34.22098, 108.978155], [34.245125, 108.95356], [34.241915, 108.927417], [34.252565, 108.93392], [34.270805, 108.910175], [34.261092, 108.875202], [34.23723, 108.913805], [34.229345, 108.898097], [34.24461, 108.867702], [34.2538, 108.85148], [34.217515, 108.89593], [34.311263, 108.92252], [34.234467, 108.895623], [34.306493, 109.033705], [34.276617, 109.04987], [34.182947, 108.969122], [34.313347, 108.9267], [34.23946, 108.891955], [34.325285, 108.94242], [34.264965, 108.89132], [34.331498, 108.921467], [34.22257, 108.90051], [34.294335, 108.939417], [34.245042, 108.958705], [34.26152, 109.058677], [34.311092, 108.945042], [34.246752, 108.765727], [34.367025, 108.990713], [34.200793, 108.982913], [34.37369, 108.935847], [34.229003, 108.942213], [34.224422, 108.924882], [34.315657, 108.955787], [34.233063, 109.003335], [34.257032, 108.93839], [34.278028, 109.02428], [34.234335, 109.07572], [34.2584, 108.907085], [34.32188, 108.93362], [34.157772, 108.92251], [34.193047, 108.936392], [34.268302, 108.942573], [34.203552, 108.982933], [34.213142, 108.959645], [34.24664, 108.868827], [34.162522, 108.940427], [34.204692, 108.941763], [34.323247, 108.993985], [34.261072, 108.879027], [34.142877, 108.940568], [34.298765, 108.817422], [34.22013, 108.927137], [34.236633, 108.915582], [34.193955, 108.93652], [34.260187, 109.001225], [34.289882, 108.82718], [34.242907, 108.907942], [34.323577, 108.954088], [34.31854, 108.966472], [34.236295, 108.971607], [34.214407, 108.90372], [34.160785, 108.940048], [34.246517, 108.889157], [34.234967, 108.894825], [34.252488, 108.914603], [34.270422, 108.90516], [34.227162, 108.94233], [34.311245, 108.777905], [34.311148, 108.99839], [34.279283, 109.045692], [34.321708, 108.86794], [34.21888, 108.996192], [34.247403, 108.958642], [34.242835, 108.943852], [34.273165, 109.024065], [34.26819, 108.942347], [34.300917, 108.818425], [34.35035, 108.933658], [34.299063, 108.942412], [34.259585, 108.947357], [34.271525, 108.940592], [34.288592, 108.942655], [34.284142, 109.03761], [34.342505, 108.931538], [34.294202, 108.94413], [34.324473, 108.8372], [34.143033, 108.870002], [34.289247, 109.005693], [34.26083, 108.913575], [34.260973, 108.932842], [34.25259, 108.918295], [34.29036, 108.835395], [34.315182, 108.949063], [34.247875, 108.867482], [34.290148, 109.019487], [34.238575, 108.944245], [34.246207, 108.918875], [34.30139, 108.990525], [34.338445, 108.95045], [34.306667, 108.942695], [34.186055, 108.911207], [34.246538, 108.990308], [34.252422, 108.95193], [34.287893, 108.882773], [34.28805, 108.81682], [34.297137, 108.944225], [34.318455, 108.967963], [34.184422, 108.936272], [34.252327, 108.914857], [34.264635, 108.974633], [34.223052, 108.917385], [34.256313, 108.958385], [34.319365, 108.935615], [34.251848, 108.958492], [34.2102, 108.885213], [34.181437, 108.871595], [34.22437, 108.94572], [34.26082, 108.906143], [34.230972, 108.941897], [34.326095, 108.93141], [34.241757, 108.877127], [34.28773, 108.942782], [34.322015, 108.966718], [34.241577, 109.00153], [34.15841, 108.921388], [34.265522, 108.918027], [34.300965, 109.072105], [34.328022, 108.925207], [34.234615, 108.872655], [34.261012, 108.947282], [34.249077, 108.958707], [34.257085, 108.939242], [34.294352, 108.928038], [34.143043, 108.940552], [34.23058, 108.970402], [34.243372, 108.898785], [34.29496, 108.981817], [34.2037, 108.98294], [34.253837, 108.874645], [34.252857, 108.91892], [34.245075, 108.958832], [34.259607, 108.947373], [34.19523, 108.864827], [34.261348, 108.86753], [34.224537, 108.923525], [34.261588, 108.96659], [34.261737, 108.927827], [34.266143, 108.927907], [34.294297, 108.909967], [34.242732, 109.011255], [34.210867, 108.934493], [34.2189, 108.996027], [34.247325, 109.043552], [34.320575, 108.942422], [34.233195, 108.922933], [34.24762, 108.918038], [34.276148, 109.024747], [34.244155, 109.00096], [34.215575, 108.88836], [34.271657, 108.946677], [34.321635, 108.958225], [34.24366, 108.867502], [34.216858, 108.958532], [34.382683, 109.064427], [34.33899, 108.939732], [34.339025, 108.94467], [34.367662, 108.99878], [34.162217, 108.940597], [34.318458, 108.968085], [34.305355, 108.942775], [34.260985, 108.92988], [34.270847, 108.915955], [34.251577, 108.94398], [34.32361, 108.991745], [34.144225, 108.941037], [34.27049, 108.84512], [34.302897, 108.979992], [34.360065, 108.937943], [34.176382, 108.855097], [34.340132, 108.937635], [34.239237, 108.868435], [34.224127, 108.91079], [34.30101, 109.057885], [34.246388, 108.964238], [34.296122, 108.942398], [34.258445, 108.907565], [34.248125, 109.001488], [34.233753, 108.917288], [34.250638, 108.867613], [34.269147, 109.02622], [34.16155, 108.859147], [34.226853, 108.91288], [34.310817, 109.05796], [34.302677, 108.990487], [34.34634, 108.943337], [34.258535, 108.942167], [34.19713, 108.9107], [34.262752, 108.970387], [34.26108, 108.90667], [34.338975, 108.938825], [34.234267, 108.888735], [34.332117, 108.97394], [34.236163, 108.923607], [34.167568, 108.940528], [34.155565, 108.940772], [34.348917, 108.926987], [34.2589, 108.942547], [34.281883, 108.927435], [34.309938, 108.930252], [34.23888, 108.873588], [34.330167, 108.925063], [34.260962, 108.949807], [34.302872, 109.005292], [34.2333, 108.94199], [34.201387, 108.941543], [34.23979, 108.842192], [34.269028, 108.962192], [34.386238, 108.98532], [34.227283, 108.8877], [34.26565, 108.995648], [34.233267, 108.921052], [34.21217, 108.89742], [34.236307, 108.95909], [34.245145, 108.940022], [34.352557, 108.9479], [34.264895, 108.893095], [34.275392, 108.868235], [34.19354, 108.900075], [34.210792, 108.923732], [34.303602, 108.9909], [34.243605, 108.899563], [34.315398, 108.966035], [34.252355, 108.934125], [34.263495, 108.94216], [34.236817, 108.899818], [34.243555, 108.942083], [34.24664, 108.889417], [34.32359, 108.986007], [34.263283, 108.950085], [34.234588, 108.920302], [34.27073, 108.902375], [34.270858, 108.979997], [34.34591, 108.925027], [34.267145, 109.009267], [34.294342, 108.933305], [34.339385, 108.967058], [34.194117, 108.936522], [34.298752, 108.919942], [34.245147, 108.948888], [34.306478, 108.979545], [34.304667, 108.970447], [34.26152, 109.058677], [34.276612, 109.04954], [34.205575, 108.972707], [34.259582, 108.989125], [34.171035, 108.94061], [34.191328, 108.93446], [34.255077, 108.958397], [34.240973, 108.927475], [34.260977, 108.93009], [34.219122, 108.892418], [34.247602, 108.972122], [34.164667, 108.928447], [34.249645, 108.901072], [34.247327, 108.93964], [34.18818, 108.876517], [34.3313, 108.943037], [34.193063, 108.935868], [34.267185, 108.82087], [34.318485, 108.933255], [34.27908, 108.996928], [34.163102, 108.87541], [34.243765, 108.949295], [34.200167, 108.908155], [34.241857, 108.885225], [34.246688, 108.865325], [34.253782, 108.863582], [34.253735, 108.88302], [34.193327, 108.900028], [34.12867, 108.895637], [34.261222, 108.98693], [34.23815, 108.887992], [34.293473, 108.937188], [34.252412, 108.953433], [34.31938, 108.945807], [34.22707, 108.938205], [34.241052, 108.92757], [34.241873, 108.893678], [34.228515, 108.942305], [34.367553, 108.997643], [34.262737, 108.942202], [34.2709, 108.986685], [34.301357, 108.808977], [34.335992, 108.933165], [34.29498, 108.982198], [34.270532, 109.009263], [34.223322, 108.898922], [34.16406, 108.950997], [34.301455, 108.97966], [34.30064, 108.75626], [34.25257, 109.017552], [34.218883, 108.975978], [34.3065, 108.944872], [34.252592, 109.034195], [34.261047, 108.940577], [34.252657, 108.948317], [34.210412, 108.93443], [34.261717, 108.820705], [34.266595, 109.03918], [34.209775, 108.869745], [34.222762, 108.89042], [34.199253, 108.99338], [34.381805, 108.933965], [34.215263, 108.961842], [34.302978, 108.97897], [34.282287, 108.89284], [34.253227, 108.915545], [34.21799, 108.962163], [34.291337, 108.835613], [34.2605, 108.93877], [34.23723, 108.95568], [34.252642, 108.948022], [34.223345, 108.917467], [34.341435, 108.961192], [34.321965, 108.933292], [34.252595, 108.955563], [34.168765, 108.99576], [34.249335, 108.942067], [34.253882, 108.967752], [34.294277, 108.895035], [34.193765, 108.936637], [34.23443, 108.905095], [34.253695, 108.947512], [34.378002, 108.907737], [34.384005, 108.977777], [34.355367, 108.972482], [34.199548, 108.943923], [34.227345, 108.866145], [34.283127, 109.058665], [34.3171, 108.961225], [34.319305, 108.94429], [34.342407, 108.925767], [34.245485, 109.001507], [34.311452, 108.98432], [34.22847, 108.942242], [34.213362, 108.881897], [34.268565, 108.941522], [34.270688, 108.904695], [34.229108, 108.927475], [34.22444, 108.958207], [34.276652, 109.037632], [34.224703, 108.966408], [34.30121, 108.942377], [34.31319, 108.837243], [34.28573, 108.966882], [34.269482, 108.962242], [34.242905, 108.923493], [34.252547, 109.03467], [34.262188, 108.991313], [34.196835, 108.936865], [34.193105, 108.936422], [34.245097, 108.918898], [34.246512, 108.988003], [34.245583, 108.9587], [34.253792, 108.883193], [34.274147, 108.849145], [34.3012, 108.939605], [34.261125, 108.921968], [34.258637, 108.95828], [34.22373, 108.941852], [34.161903, 108.943468], [34.243637, 108.899435], [34.284745, 108.85208], [34.297372, 109.018645], [34.138022, 108.875065], [34.278387, 109.053972], [34.268767, 108.9622], [34.238595, 108.944177], [34.202965, 108.94179], [34.271422, 108.943442], [34.23867, 108.88217], [34.206583, 108.981748], [34.309902, 108.938032], [34.166122, 108.910167], [34.205397, 108.941843], [34.28342, 108.99865], [34.270855, 108.989162], [34.264803, 108.990572], [34.31935, 108.934885], [34.181512, 108.965562], [34.251882, 108.941488], [34.229065, 108.959233], [34.308205, 108.942667], [34.162567, 108.9404], [34.306125, 108.93356], [34.2706, 108.88415], [34.389445, 108.959737], [34.221737, 108.880138], [34.095762, 108.954437], [34.28614, 108.942687], [34.3818, 108.933968], [34.221387, 108.903358], [34.252122, 108.939797], [34.294312, 108.967137], [34.24328, 108.989498], [34.25923, 108.885397], [34.270565, 108.878493], [34.29117, 108.826635], [34.227942, 108.92741], [34.271497, 108.912728], [34.237178, 108.922348], [34.248815, 108.942327], [34.289892, 108.827152], [34.148552, 108.879725], [34.240172, 108.892467], [34.282452, 108.91606], [34.314483, 108.971143], [34.281867, 108.939503], [34.192988, 108.942903], [34.261207, 108.987545], [34.243547, 108.90533], [34.278415, 108.990555], [34.240005, 108.892363], [34.19296, 108.941262], [34.043677, 108.712547], [34.234258, 108.942253], [34.221132, 108.887965], [34.261382, 108.990842], [34.224423, 108.92158], [34.213425, 108.931993], [34.213163, 108.961277], [34.301, 108.942897], [34.26096, 108.929727], [34.259575, 108.947327], [34.216927, 108.949055], [34.440712, 108.755792], [34.208677, 108.914928], [34.345095, 108.972282], [34.323582, 108.994737], [34.231517, 108.872572], [34.20777, 108.864545], [34.249745, 108.967655], [34.261198, 108.94747], [34.19306, 108.92676], [34.210028, 108.915008], [34.291012, 108.82813], [34.281877, 108.92802], [34.212728, 109.008067], [34.306758, 108.942652], [34.270927, 108.991867], [34.27901, 108.989115], [34.201142, 108.951763], [34.341172, 108.960685], [34.175033, 108.842122], [34.21344, 108.931938], [34.315335, 108.944122], [34.161177, 108.9525], [34.196225, 108.984872], [34.323692, 108.940998], [34.220405, 108.942202], [34.218017, 108.95618], [34.252558, 109.037907], [34.235302, 108.927482], [34.22687, 108.951808], [34.281087, 109.063575], [34.231895, 108.944907], [34.28181, 109.038442], [34.227875, 108.927395], [34.26042, 109.01331], [34.199415, 108.964963], [34.294363, 108.946238], [34.279275, 108.99092], [34.34891, 108.925863], [34.261242, 108.946962], [34.27059, 108.942363], [34.224513, 108.940893], [34.260765, 108.968415], [34.21184, 108.942125], [34.222127, 108.965362], [34.319432, 108.9395], [34.26253, 109.04014], [34.417958, 108.98639], [34.195567, 108.878662], [34.207312, 108.914918], [34.24466, 108.877227], [34.256035, 108.931342], [34.245702, 108.867655], [34.212362, 109.006682], [34.457493, 109.000077], [34.192608, 108.978535], [34.258855, 108.942507], [34.2737, 109.067222], [34.2831, 109.057982], [34.27245, 108.86729], [34.316315, 108.984078], [34.253727, 108.943155], [34.285425, 109.009025], [34.323205, 108.966642], [34.238517, 108.94425], [34.257075, 108.938435], [34.227318, 108.882037], [34.18549, 108.975082], [34.252657, 108.948605], [34.159697, 108.886855], [34.242932, 108.970687], [34.283752, 109.057557], [34.213565, 108.909118], [34.219802, 108.87722], [34.27164, 108.941667], [34.32625, 108.929792], [34.28113, 108.990553], [34.338437, 108.954563], [34.279453, 108.942695], [34.381777, 108.933912], [34.248435, 108.942355], [34.28658, 108.917357], [34.30651, 108.945737], [34.301252, 108.939343], [34.196465, 108.870938], [34.213475, 108.897195], [34.294412, 108.945845], [34.200592, 108.94254], [34.216892, 108.947107], [34.238545, 108.886985], [34.159725, 108.934527], [34.167725, 108.940618], [34.279025, 108.990282], [34.271202, 108.928972], [34.37618, 108.976507], [34.237195, 108.922617], [34.223463, 108.924742], [34.312463, 109.011955], [34.294298, 108.89595], [34.29231, 108.942183], [34.260922, 108.890858], [34.260417, 108.816655], [34.306545, 108.943783], [34.283642, 108.830133], [34.224473, 108.943305], [34.276692, 108.86498], [34.284147, 108.997828], [34.294312, 108.909502], [34.297167, 108.939567], [34.245922, 108.877083], [34.242917, 108.952247], [34.227927, 108.910395], [34.25186, 108.943125], [34.371245, 108.964038], [34.260997, 108.954225], [34.224218, 108.957832], [34.323457, 108.984012], [34.22783, 108.910615], [34.213358, 108.895117], [34.244412, 108.87701], [34.28778, 108.917238], [34.244297, 108.942092], [34.244392, 108.942005], [34.229777, 108.927215], [34.283777, 108.88863], [34.24276, 108.9], [34.1854, 108.940892], [34.311725, 108.948923], [34.213597, 108.919667], [34.223032, 108.92716], [34.247033, 108.889935], [34.249042, 108.918727], [34.302883, 109.007135], [34.294358, 108.944373], [34.21013, 108.885142], [34.227188, 108.943275], [34.27155, 108.776602], [34.25993, 108.867532], [34.181367, 108.873607], [34.35949, 108.933907], [34.199925, 108.940225], [34.241973, 108.927575], [34.251617, 108.944157], [34.26634, 108.889993], [34.26305, 108.962237], [34.239105, 108.979413], [34.337972, 108.933267], [34.362057, 108.907537], [34.227517, 108.75983], [34.223615, 108.941713], [34.275997, 109.037977], [34.224158, 108.91086], [34.232055, 108.927307], [34.353923, 108.943773], [34.350115, 108.949055], [34.276347, 108.957937], [34.254785, 108.918613], [34.246647, 108.872235], [34.252635, 109.014135], [34.257105, 108.8851], [34.24298, 108.95234], [34.1877, 108.971585], [34.315325, 108.92737], [34.257255, 108.935047], [34.221662, 108.871705], [34.143033, 108.870002], [34.22491, 108.965315], [34.323565, 108.994537], [34.216475, 108.924635], [34.239953, 108.984317], [34.247585, 108.942578], [34.28229, 108.905585], [34.174997, 108.88762], [34.223555, 108.942297], [34.227145, 108.943105], [34.236665, 108.915645], [34.38396, 109.056642], [34.258137, 108.942587], [34.261195, 108.92919], [34.339862, 108.911795], [34.287835, 108.928545], [34.257137, 108.935538], [34.287867, 108.893097], [34.242607, 108.927735], [34.33226, 109.008355], [0.0, 0.0], [34.334997, 108.9451], [34.252587, 109.034175], [34.226447, 108.927198], [34.294353, 108.947047], [34.351167, 108.949133], [34.198485, 108.940678], [34.180023, 108.97759], [34.294357, 108.919947], [34.254727, 108.896525], [34.25865, 108.942243], [34.32762, 108.919147], [34.338987, 108.926113], [34.279418, 108.99094], [34.26099, 108.909292], [34.170612, 108.893302], [34.309002, 108.942675], [34.252322, 108.896095], [34.1697, 108.922232], [34.246867, 108.881597], [34.362432, 108.951122], [34.270117, 108.990545], [34.249825, 108.872005], [34.25969, 108.885397], [34.221077, 108.904107], [34.254045, 108.931413], [34.170573, 108.875583], [34.252542, 109.03912], [34.207882, 108.934312], [34.258535, 108.918565], [34.22106, 108.904118], [34.271283, 108.962168], [34.23707, 109.000442], [34.227757, 108.966785], [34.266073, 108.962292], [34.171327, 108.940615], [34.260962, 108.93685], [34.355285, 108.939512], [34.242658, 108.898538], [34.316577, 109.121135], [34.239322, 108.891912], [34.26719, 108.91547], [34.278488, 108.955282], [34.2538, 108.871793], [34.294298, 108.908808], [34.295762, 108.926962], [34.260472, 109.004335], [0.0, 0.0], [34.203608, 108.951832], [34.184587, 108.970612], [34.251287, 108.967625], [34.233772, 108.906533], [34.221147, 108.903897], [34.247435, 108.918732], [34.289812, 108.835023], [34.171178, 108.940577], [34.281672, 108.94392], [34.216778, 108.836138], [34.213163, 108.959687], [34.195313, 108.864955], [34.213482, 108.896932], [34.241885, 108.927535], [34.28142, 108.957705], [34.312318, 109.002243], [34.22444, 108.945765], [34.242802, 108.932265], [34.217507, 108.927248], [34.247935, 109.04207], [34.244492, 108.958708], [34.29432, 108.969952], [34.242622, 108.978777], [34.338077, 109.011232], [34.242387, 108.877252], [34.259025, 108.958487], [34.331457, 108.943542], [34.242645, 108.9433], [34.342462, 108.92878], [34.23233, 109.014912], [34.242553, 108.900362], [34.260967, 108.931452], [34.099868, 108.79535], [34.341655, 108.932955], [34.186653, 108.940763], [34.24277, 108.894307], [34.225293, 108.927205], [34.299612, 108.940467], [34.276095, 109.060963], [34.27139, 108.96885], [34.257627, 108.94436], [34.254203, 108.94305], [34.234962, 108.945497], [34.223807, 108.910852], [34.251587, 108.94381], [34.251557, 108.943827], [34.287873, 108.915782], [34.306475, 108.943137], [34.199762, 108.914822], [34.249825, 108.905502], [34.268712, 108.9574], [34.288892, 109.0566], [34.211112, 109.000622], [34.161595, 108.855075], [34.206593, 108.976127], [34.330767, 108.955537], [34.221718, 108.87865], [34.224042, 108.97235], [34.19944, 108.940777], [34.21923, 108.891055], [34.236495, 108.902312], [34.294302, 108.893995], [34.233563, 108.945913], [34.223503, 108.942283], [34.239107, 108.949135], [34.237193, 108.95619], [34.252318, 108.935142], [34.259615, 108.942463], [34.226792, 108.91977], [34.241027, 108.927538], [34.216545, 108.885167], [34.26237, 108.94257], [34.312442, 109.011792], [34.296985, 108.942382], [34.242717, 108.959412], [34.338827, 108.960737], [34.212903, 108.934457], [34.36604, 108.998777], [34.22929, 108.96993], [34.25956, 108.942443], [34.214552, 109.004487], [34.166017, 108.91258], [34.234287, 108.889408], [34.253775, 108.962205], [34.319375, 108.944487], [34.23808, 108.888133], [34.299733, 108.942615], [34.287872, 108.91492], [34.376262, 108.976433], [34.242123, 108.893797], [34.312425, 108.778897], [34.261158, 108.943375], [34.334272, 108.919067], [34.123078, 108.93443], [34.237852, 108.867632], [34.248805, 108.928255], [34.230243, 108.885132], [34.283395, 108.942343], [34.15828, 108.92386], [34.251915, 108.94311], [34.144595, 108.941095], [34.299897, 108.814258], [34.308732, 108.939255], [34.282515, 108.99786], [34.23268, 108.990292], [34.278755, 108.867182], [34.244562, 108.958732], [34.204083, 108.894627], [34.231532, 108.902727], [34.240267, 108.984067], [34.374852, 108.947095], [34.237912, 108.902855], [34.233442, 108.941945], [34.22349, 108.942297], [34.339005, 108.944687], [34.227495, 108.868182], [34.236518, 108.934375], [34.338918, 108.928], [34.175307, 108.847378], [34.342128, 108.91505], [34.218125, 108.910313], [34.318448, 108.967652], [34.237187, 108.94954], [34.267433, 108.956988], [34.260953, 108.92974], [34.21959, 108.915093], [34.162517, 108.940405], [34.28292, 108.891132], [34.268697, 109.00849], [34.332222, 108.92522], [34.320795, 108.97122], [34.279995, 109.065705], [34.328565, 108.92593], [34.219882, 108.95159], [34.273983, 109.062867], [34.2242, 108.95793], [34.18296, 108.970625], [34.231052, 108.922492], [34.262818, 109.040807], [34.27092, 108.988122], [34.237062, 108.94457], [34.241035, 108.92758], [34.352845, 108.949073], [34.188325, 108.93842], [34.284303, 108.96672], [34.247627, 108.97296], [34.257067, 108.938333], [34.2951, 109.019012], [34.29022, 108.906588], [34.331762, 109.047577], [34.261187, 108.953687], [34.21635, 108.905453], [34.229138, 108.995962], [34.226578, 108.927377], [34.290733, 108.827103], [34.316833, 108.971133], [34.239782, 108.84219], [34.368598, 108.991257], [34.234332, 108.941975], [34.282728, 108.967438], [34.27544, 109.024425], [34.297203, 108.945185], [34.22677, 108.942255], [34.25234, 108.909263], [34.351935, 108.933488], [34.361137, 108.925012], [34.252332, 108.883388], [34.32539, 108.942422], [34.239635, 109.028393], [34.260992, 108.96986], [0.0, 0.0], [34.229213, 108.927345], [34.308233, 108.792852], [34.294307, 108.925305], [34.19561, 108.876802], [34.309533, 108.942592], [34.223587, 108.941818], [34.342493, 108.931647], [34.251125, 108.943492], [34.202697, 108.923717], [34.3236, 108.962107], [34.223412, 108.86857], [34.221045, 108.90408], [34.279202, 108.990963], [34.252578, 109.034547], [34.262395, 108.877223], [34.252165, 108.945277], [34.218135, 108.910305], [34.252687, 108.970727], [34.209572, 108.987812], [34.20915, 108.934503], [34.234457, 108.92365], [34.23005, 108.942257], [34.300967, 109.018307], [34.339877, 108.942847], [34.308355, 108.942652], [34.268885, 108.958427], [34.261967, 108.927905], [34.21813, 108.876065], [34.23715, 108.925113], [34.261625, 108.974415], [34.210152, 108.942098], [34.288682, 108.9427], [34.306505, 108.944278], [34.260642, 108.848248], [34.246982, 108.880112], [34.216855, 108.956503], [34.239637, 108.843168], [34.24192, 108.942343], [34.38354, 108.96659], [34.314502, 108.77992], [34.286157, 108.847652], [34.256555, 109.029403], [34.186527, 108.991655], [34.299565, 108.940275], [34.256948, 108.958435], [34.244145, 108.988385], [34.253572, 108.89134], [34.323052, 108.955522], [34.252522, 109.03911], [34.30958, 109.013477], [34.196507, 108.985907], [34.29437, 108.94457], [34.260952, 108.969772], [34.275855, 108.997692], [34.34592, 108.933145], [34.241343, 108.903328], [34.252463, 108.984278], [34.26331, 108.966125], [34.342495, 108.929823], [34.2211, 108.903863], [34.28926, 109.000895], [34.26337, 108.950285], [34.26478, 108.899467], [34.265827, 108.959655], [34.23014, 108.934545], [34.15902, 108.90358], [34.323837, 108.99118], [34.316697, 108.942467], [34.25207, 108.94516], [34.323615, 108.962425], [34.293512, 108.836305], [34.25759, 108.945187], [34.265983, 108.970007], [34.219992, 108.983957], [34.271238, 108.932985], [34.315692, 108.942675], [34.290705, 108.830135], [34.226552, 108.900018], [34.164355, 108.932817], [34.287923, 108.972618], [34.224437, 108.9228], [34.24432, 108.873843], [34.231702, 108.971505], [34.23524, 108.967813], [34.315565, 108.998667], [34.23611, 108.942287], [34.180302, 108.885427], [34.29323, 108.906643], [34.25749, 108.946518], [34.199348, 108.970268], [34.22879, 108.927377], [34.27948, 108.990952], [34.290242, 109.040498], [34.16124, 108.848402], [34.258933, 108.934262], [34.2169, 108.959215], [34.24759, 108.961297], [34.275185, 108.941057], [34.24713, 108.890037], [34.258867, 108.942463], [34.275548, 109.045682], [34.323577, 108.98723], [34.257507, 108.946818], [34.147233, 108.933998], [34.260345, 108.921292], [34.168733, 108.950663], [34.231708, 109.034517], [34.177717, 108.887578], [34.182967, 108.875485], [34.251745, 108.945315], [34.234245, 108.875875], [34.355507, 108.992538], [34.250727, 108.945263], [34.28944, 109.068047], [34.232575, 108.99006], [34.23974, 108.958842], [34.311293, 108.992295], [34.294357, 108.920468], [34.344707, 108.933052], [34.278455, 108.990532], [34.259515, 108.94722], [34.261065, 108.916093], [34.21579, 109.00753], [34.353923, 108.943525], [34.252575, 108.933205], [34.241055, 108.927535], [34.281852, 108.928062], [34.232823, 108.9458], [34.294263, 108.903223], [34.257095, 108.884857], [34.24194, 108.92683], [34.320955, 108.958193], [34.276323, 109.037718], [34.208397, 108.96926], [34.269923, 108.828338], [34.254043, 108.963997], [34.24865, 108.941997], [34.260932, 108.883937], [34.265623, 108.985407], [34.271145, 108.983367], [34.26804, 108.990873], [34.213257, 108.959675], [34.326047, 108.942447], [34.31535, 108.92628], [34.308105, 108.942712], [34.235855, 108.899032]],
            {&quot;blur&quot;: 15, &quot;maxZoom&quot;: 18, &quot;minOpacity&quot;: 0.5, &quot;radius&quot;: 25}
        );


        heat_map_cb6892288324792f5f8c8d124591c195.addTo(map_aef33a1e49a07948a240f2698fab96ba);


        tile_layer_d49a6a09a9249b0ac3d1872719fa91af.addTo(map_aef33a1e49a07948a240f2698fab96ba);


        heat_map_cb6892288324792f5f8c8d124591c195.addTo(map_aef33a1e49a07948a240f2698fab96ba);


        tile_layer_d49a6a09a9249b0ac3d1872719fa91af.addTo(map_aef33a1e49a07948a240f2698fab96ba);


        heat_map_cb6892288324792f5f8c8d124591c195.addTo(map_aef33a1e49a07948a240f2698fab96ba);

</script>
</html>" style=“position:absolute;width:100%;height:100%;left:0;top:0;border:none !important;” allowfullscreen webkitallowfullscreen mozallowfullscreen>

from bokeh.embed import components
from bokeh.resources import INLINE

js_resources = INLINE.render_js()  # 基本图形比较简单js和css通用
css_resources = INLINE.render_css()
script,div = components(layout)  # 可以在Flask路由中嵌入展示

示例

@main.route(‘/’, methods=[‘GET’])
@login_required
def index():
return render_template(‘index.html’,
js_resources=js_resources,
css_resources=css_resources,
plot_script=script,
plot_div=div,
)

bokeh独立实现

import math
# 经纬度转为墨卡托坐标系
def lonLat2WebMercator(lon,Lat):
    x = lon *20037508.34/180;
    y = math.log(math.tan((90+Lat)*math.pi/360))/(math.pi/180)
    y = y *20037508.34/180;
    return x,y
def lonLat2WebMercator_Lon(lon):  #GPS经度
    x = lon *20037508.34/180
    return x
def lonLat2WebMercator_Lat(Lat):  # GPS纬度
    y = math.log(math.tan((90+Lat)*math.pi/360))/(math.pi/180)
    y = y *20037508.34/180
    return y
df_new=df_gao.copy()
df_new.head()
get_on_timeget_off_timewait_timemoneyon_lonon_latmonthday
02022/6/6 11:276/6/2022 11:48:0136022.1108.84365234.28408266
12022/6/6 11:486/6/2022 12:03:0112015.1108.92121034.26169066
22022/6/6 12:086/6/2022 12:20:016020.1108.86915034.28814066
32022/6/6 12:336/6/2022 12:49:0018013.9108.83724034.30733266
42022/6/6 12:546/6/2022 13:01:011208.5108.86726034.27439066
df_new["Lon"] = df_new["on_lon"].apply(lonLat2WebMercator_Lon)
df_new["Lat"] = df_new["on_lat"].apply(lonLat2WebMercator_Lat)
from bokeh.plotting import figure, save
from bokeh.util.browser import view
from bokeh.document import Document
from bokeh.resources import INLINE
from bokeh.models import Plot
from bokeh.models import Range1d
from bokeh.models import WheelZoomTool, PanTool, BoxZoomTool
from bokeh.models import WMTSTileSource

# 设置x,y轴的经纬度范围,自动受地图高宽影响
# x_range = Range1d(int(df_new["Lon"].min()),int(df_new["Lon"].max()))
# y_range = Range1d(int(df_new["Lat"].min()),int(df_new["Lat"].max()))
# 手动
lon_min = lonLat2WebMercator_Lon(107.663498)  # 经度最小
lon_max = lonLat2WebMercator_Lon(109.815857)  # 经度最大
lat_min = lonLat2WebMercator_Lat(33.695789)  # 纬度最小
lat_max = lonLat2WebMercator_Lat(34.745953)  # 纬度最大
y_range = Range1d(lat_min,lat_max)
x_range = Range1d(lon_min,lon_max)

tile_options = {}
tile_options['url'] = 'http://webrd02.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=7&x={x}&y={y}&z={z}'  # style=7,8
tile_options['attribution'] = """
   '&copy; <a href="https://intumu.com/">@intumu.com</a>.
    """ # 地图右下角标签
tile_source = WMTSTileSource(**tile_options)
# 实例化plot
p = figure(x_range=x_range, y_range=y_range, height=800, width=1000,x_axis_type="mercator", y_axis_type="mercator")
# 标记区域
p.scatter(df_new['Lon'], df_new['Lat'],size=5, marker="circle", color="red", alpha=0.99,legend_label='乘车点') 
# 渲染地图
p.add_tools(BoxZoomTool(match_aspect=True))  # WheelZoomTool(), PanTool(), 
tile_renderer_options = {}
p.add_tile(tile_source, **tile_renderer_options)

# 其他参数
p.xaxis.visible = False
p.yaxis.visible = False 
p.xgrid.grid_line_color = None 
p.ygrid.grid_line_color = None 
p.legend.orientation = "horizontal"
p.legend.location = "top_center"
p.legend.click_policy="hide" # 点击图例显示、隐藏图形
p.sizing_mode = 'scale_width'
# 显示
show(p)
# 将 Bokeh 图表保存为 HTML 文件
# save(p, filename="my_plot.html")

在这里插入图片描述
在这里插入图片描述



  • 21
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值