出租车数据的地图展示

出租车数据的地图展示

实现方法

python数据预处理后将数据导入地图代码。

效果

出租车数据的地图展示_第1张图片

数据预处理:

f1['dropoff_longitude'].fillna(value=f1['dropoff_longitude'].mean(), inplace=True)
plt.boxplot(f1["dropoff_longitude"])
plt.show()
#超过了上四分位1.5倍四分位距或下四分位1.5倍距离都算异常值,用中位数填充
a = f1["dropoff_longitude"].quantile(0.75)
b = f1["dropoff_longitude"].quantile(0.25)
c = f1["dropoff_longitude"]
c[(c>=(a-b)*1.5+a)|(c<=b-(a-b)*1.5)]=np.nan
c.fillna(c.median(),inplace=True)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.5&ak= 你的密钥 "></script>
    <style type="text/css">
        #c {
            height: 469px;
            width: 1092px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div id="c">
   
    </div>
    <script type="text/javascript">
    var map=new BMap.Map("c", {});//BMap类 
    var point=new BMap.Point(116 ,40);//创建点
    map.centerAndZoom(point, 1); //初始化,中心点,地图级别              Zoom 快速移动; 迅速前往; 急剧增长; 猛涨; 
    map.addControl(new BMap.NavigationControl()); //添加缩放控件          导航; 领航; 航行;
    map.enableScrollWheelZoom();                        //启用滚轮放大缩小








    var maker =new BMap.Marker(point);//标注 maker
    map.addOverlay(maker);
 

    var mapPoints = [
                {x:30.312903,y:120.382029},
                {x:30.215855,y:120.024568},
                {x:30.18015,y:120.174968},
                {x:30.324994,y:120.164399},
                {x:-7,y:40},
                {x:40.754917,y:-73.993747},
                {x:40.740835,y:-74.004935},
{x:40.720343,y:-73.99816},
{x:40.755638,y:-73.98672999999998},
{x:40.704618,y:-74.01587999999998},
{x:40.74078,y:-74.00544999999998},
{x:40.729573,y:-73.981567},
{x:40.823673,y:-73.95259799999998},
{x:40.766333,y:-73.982383},
{x:40.741675,y:-73.98980199999998},
{x:40.750325,y:-73.99473299999998},
{x:0.0,y:0.0},
{x:40.773355,y:-73.962063},
{x:40.720665,y:-73.997725},
{x:40.75872,y:-73.989013},
{x:40.720495,y:-74.010165},
{x:40.75082,y:-73.97650799999998},
{x:40.77047,y:-73.984325},
{x:40.731163,y:-73.988735},
{x:40.760867,y:-73.987037},
{x:40.746852,y:-73.981142},
{x:40.740082,y:-74.006163},
{x:40.758137,y:-73.976532},
{x:40.773623,y:-73.959692},
{x:40.770402,y:-73.855753},
{x:40.750183,y:-73.987837},
{x:40.804635,y:-73.955488},
{x:40.729485,y:-73.987092},
{x:40.725277,y:-73.99675499999998},
{x:40.735193,y:-74.00588},
{x:40.780737,y:-73.95682499999998},
{x:40.765618,y:-73.96321},
{x:40.756055,y:-73.97844999999998},
{x:40.752703,y:-73.993138},
{x:40.759485,y:-73.96203},
{x:40.706353,y:-74.006027},
{x:40.772355,y:-73.96286499999998},
{x:40.738868,y:-73.985228},
{x:40.794173,y:-73.962968},
{x:40.77817,y:-73.948408},
{x:40.767787,y:-73.96217199999998},
{x:40.756412,y:-73.99041699999998},
{x:40.797943,y:-73.963767},
{x:40.764847,y:-73.97286699999998},
{x:40.645132,y:-73.77605},
{x:40.720092,y:-73.98831},
{x:40.71722,y:-74.01273999999998},
{x:40.746608,y:-73.979303},
{x:40.766872,y:-73.97727299999998},
{x:40.755426,y:-73.927312},
{x:40.751101,y:-73.994124},
{x:40.72093,y:-74.005448},
{x:40.722353,y:-73.986203},
{x:40.723707,y:-73.99458799999998},
{x:40.737548,y:-73.99678199999998},
{x:40.786088,y:-73.972328},
{x:40.743717,y:-73.999707},
{x:40.772768,y:-73.95554},
{x:40.746827,y:-73.98398199999998},
{x:40.745782,y:-73.982028},
{x:40.738758,y:-73.993843},
{x:40.745497,y:-73.978207},
{x:40.745185,y:-73.995022},
{x:0.0,y:0.0},
{x:40.802638,y:-73.94297299999998},
{x:40.757907,y:-73.973819},
{x:40.770902,y:-73.956933},
{x:40.736863,y:-73.986188},
{x:40.670848,y:-73.98496},
{x:40.765877,y:-73.96536299999998},
{x:0.0,y:0.0},
{x:40.80898,y:-73.959638},
{x:40.770307,y:-73.96921},
{x:40.744277,y:-73.976067},
{x:40.730712,y:-74.001743},
{x:40.711357,y:-74.010597},
{x:40.76372,y:-73.962322},
{x:40.738682,y:-73.990048},
{x:40.761478,y:-73.968625},
{x:40.761548,y:-73.975093},
{x:40.775572,y:-73.947548},
{x:40.740059,y:-73.99478999999998},
{x:40.761457,y:-73.9852},
{x:40.739943,y:-74.00688499999998},
{x:40.75604,y:-73.98654999999998},
{x:40.760502,y:-73.98704999999998},
{x:40.77801,y:-73.978351},
{x:40.732358,y:-74.003698},
{x:40.787225,y:-73.942035},
{x:40.74508,y:-73.984682},
{x:0.0,y:0.0},
{x:40.75891,y:-73.968715},
{x:40.803765,y:-73.96685499999998},
{x:40.732813,y:-74.000183},
{x:40.730095,y:-73.983362},
{x:40.795162,y:-73.971745},
{x:0.0,y:0.0},
{x:40.783758,y:-73.980241},
{x:40.76286,y:-73.985943},
{x:40.723908,y:-73.991319},
{x:40.709301,y:-74.01061699999998},
{x:40.782405,y:-73.94854599999998},
{x:40.789233,y:-73.943545},
{x:40.773943,y:-73.87299},
{x:40.741548,y:-74.006668},
{x:40.746938,y:-74.004644},
{x:40.71404,y:-73.99034},
{x:40.765312,y:-73.98759699999998},
{x:40.759445,y:-73.995517},
{x:40.645394,y:-73.77655699999998},
{x:40.720617,y:-74.01096699999998},
{x:40.747617,y:-74.003837},
{x:40.77642,y:-73.96231799999998},
{x:40.759842,y:-73.969773},
{x:40.751901,y:-73.97733599999998},
{x:40.785207,y:-73.973173},
{x:40.788633,y:-73.955252},
{x:40.72714,y:-74.00013699999998},
{x:40.765267,y:-73.976123},
{x:40.741271,y:-74.000262},
{x:40.739759,y:-73.97643999999998},
{x:40.720462,y:-73.992733},
{x:40.735343,y:-73.975345},
{x:40.751982,y:-73.939385},
{x:40.7201,y:-73.988045},
{x:40.782758,y:-73.95537199999998},
{x:40.768715,y:-73.961505},
{x:40.721468,y:-73.99981699999998},
{x:0.0,y:0.0},
{x:40.743002,y:-73.99311199999998},
{x:40.750517,y:-73.996617},
{x:40.760358,y:-73.991313},
{x:40.773707,y:-73.870863},
{x:40.7721,y:-73.950157},
{x:40.78953,y:-73.96987},
{x:40.735289,y:-73.985619},
{x:40.769283,y:-73.961095},
{x:40.754768,y:-73.973393},
{x:40.722898,y:-73.99845999999998},
{x:40.757375,y:-73.963507},
{x:40.77562,y:-73.98773199999998},
{x:40.723362,y:-74.003005},
{x:40.772503,y:-73.952565},
{x:40.780292,y:-73.953083},
{x:40.746002,y:-73.97811},
{x:40.716305,y:-73.99181299999998},
{x:40.750572,y:-73.979207},
{x:40.771385,y:-73.965815},
{x:40.714775,y:-74.006023},
{x:40.656983,y:-73.982732},
{x:40.724955,y:-73.99468799999998},
{x:40.72929,y:-74.002173},
{x:40.720361,y:-73.993725},
{x:40.729512,y:-74.002228},
{x:40.758277,y:-73.98640799999998},
{x:40.76017,y:-73.97597399999998},
{x:40.720322,y:-74.001123},
{x:40.648377,y:-73.78890199999998},
{x:40.762215,y:-73.985922},
{x:40.75323,y:-73.97472999999998},
{x:40.773968,y:-73.87264299999998},
{x:40.756038,y:-73.970203},
{x:40.755634,y:-73.97246},
{x:40.7696,y:-73.95473699999998},
{x:40.776888,y:-73.95232199999998},
{x:40.767889,y:-73.962055},
{x:40.701746,y:-74.01138},
{x:40.764676,y:-73.971455},
{x:40.724548,y:-73.987548},
{x:40.755856,y:-73.964968},
{x:40.723289,y:-74.00793799999998},
{x:40.74024,y:-74.002277},
{x:40.760207,y:-73.960552},
{x:40.74554,y:-73.97769599999998},
{x:40.735653,y:-73.994359},
{x:40.756236,y:-73.990379},
{x:40.759624,y:-73.99190799999998},
{x:40.78309,y:-73.95881699999998},
{x:40.776072,y:-73.987655},
{x:40.722081,y:-73.988211},
{x:40.711385,y:-74.015895},
{x:40.78408,y:-73.954575},
{x:40.78353,y:-73.947767},
{x:40.769473,y:-73.984476},
{x:40.757036,y:-73.98954999999998},
{x:40.761256,y:-73.98363},
{x:40.751262,y:-73.974573},
{x:40.7187,y:-73.988327},
{x:40.742369,y:-73.980596},
{x:40.811727,y:-73.960808},
{x:40.779052,y:-73.960341},
{x:40.76221,y:-73.972432},
{x:40.762809,y:-73.982377},
{x:40.729834,y:-73.974731},
{x:40.779814,y:-73.95598099999998},
{x:40.734816,y:-73.988236},
{x:40.766686,y:-73.96277999999998},
{x:40.713147,y:-74.03793299999998},
{x:40.743919,y:-73.98777599999998},
{x:40.764472,y:-73.96661899999998},
{x:40.747548,y:-73.987981},
{x:40.765296,y:-73.980333},
{x:40.752199,y:-73.977737},
{x:40.78312,y:-73.978294},
{x:40.734675,y:-73.98603799999998},
{x:40.77173,y:-73.98201199999998},
                {x:-93,y:39}
                
            ];
            var i = 0;
            function markerFun (points) {
                var markers = new BMap.Marker(points);
                map.addOverlay(markers);
            }
            for (;i<mapPoints.length;i++) {
                var points = new BMap.Point(mapPoints[i].y,mapPoints[i].x);//创建坐标点
                markerFun(points);
            }


/*
   // var myLabel = new BMap.Label("东门", { offset: new BMap.Size(-50, -50), position:point }); //offset 相对位置
    //myLabel.setTitle("某某公司"); //提示信息
    map.addOverlay(myLabel);

    var polyline = new BMap.Polyline([
    new BMap.Point(  ),
    new BMap.Point(  ),
    new BMap.Point(  )
    ]);
    map.addOverlay(polyline);





    var traffic = new BMap.TrafficLayer(); //创建交通图层
    function b() {
        
        map.addTileLayer(traffic);
    }
    function c() {
        
        map.removeTileLayer(traffic);
    }
*/
    </script>

    
    </form>
    <p>
      
</body>
</html>

你可能感兴趣的:(其他)