美文网首页GIS&LBSGeomatics(GIS,GPS,RS,Surveying)
硬核 | 高德交通大数据爬取与Python可视化(含数据分享)

硬核 | 高德交通大数据爬取与Python可视化(含数据分享)

作者: 中原百科 | 来源:发表于2019-06-02 12:32 被阅读103次

    <section class="xmteditor" style="display:none;" data-tools="新媒体管家" data-label="powered by xmt.cn"></section><section class="xmt-style-block" data-style-type="5" data-tools="新媒体排版" data-id="2154548"><section class="KolEditor" style="border-width: 0px;border-style: none;border-color: initial;padding: 0px;margin-top: 20px;"><section style="border-width: 0px;border-style: none;border-color: initial;"><section style="text-align: center;white-space: normal;"><p style="color:#f05454;" class="active brush">前言</p></section><p style="text-align: center;white-space: normal;"><img class="" data-ratio="0.05555555555555555" src="https://img.haomeiwen.com/i11473451/7cce243051eb06a3" data-type="png" data-w="180"></p></section></section></section><section class="xmt-style-block" data-style-type="5" data-tools="新媒体排版" data-id="2154549"><section class="KolEditor" style="box-sizing: border-box;border-width: 0px;border-style: none;border-color: initial;padding: 0px;margin-top: 17px;"><section class="active brush" style="margin: 3px auto;padding: 15px;color: rgb(121, 121, 121);line-height: 24px;box-shadow: rgb(170, 170, 170) 0px 0px 3px;border-width: 2px;border-style: solid;border-color: rgb(240, 240, 240);"><p>今天的文章呢主要目的不是爬虫,而是爬虫的同时顺便实现<strong>实时可视化</strong>。上次爬摩拜单车数据的文章使用的是传统的ArcGIS进行自定义可视化,<p><span style="color: #8d8d8d;">硬核 | Python多线程爬取摩拜单车数据与ArcGIS可视化</span></p>,今天我想给大家分享的是QGIS可视化(<strong>MapBox</strong>在线底图)和Python可视化。</p></section><section style="display: block;width: 0;height: 0;clear: both;"><br /></section></section></section><p><br /></p><p style="text-align: center;"><img class="rich_pages" data-copyright="0" data-ratio="0.8015625" src="https://img.haomeiwen.com/i11473451/df67093450e2e1bc" data-type="gif" data-w="640" style="text-align: center;white-space: normal;"></p><section class="xmt-style-block" data-style-type="5" data-tools="新媒体排版" data-id="2154548"><section class="KolEditor" style="border-width: 0px;border-style: none;border-color: initial;padding: 0px;margin-top: 20px;"><section style="border-width: 0px;border-style: none;border-color: initial;"><section style="text-align: center;white-space: normal;"><p style="color:#f05454;" class="active brush">高德交通大数据爬取<br /></p></section><p style="text-align: center;white-space: normal;"><img class="" data-ratio="0.05555555555555555" src="https://img.haomeiwen.com/i11473451/4819f6628d91a642" data-type="png" data-w="180"></p></section></section></section><p style="text-align: left;">本数据是由人送外号数据帝的CSDN排名1万+的博主<strong>小猿猴GIS</strong>发现的,我们其实想过到底要不要写篇文章公开(最后还是公开了,数据共享嘛)。因为之前我写过一篇<span style="text-align: center;">爬取的全国各省市实时<strong>QQ登录人数数据</strong>,公开数据爬取接口和源代码之后没多腾讯就关闭了这个</span><span style="text-align: center;">接口,要是说因为我那篇文章导致的封接口可能太高看我自己了<img src="https://img.haomeiwen.com/i11473451/3eac25b33161b122.png" data-ratio="1" data-type="xmt-emoji" data-w="19" style="display:inline-block;width:20px;vertical-align:text-bottom;" /></span><span style="text-align: center;">,但是</span><span style="text-align: center;">QQ登录人数数据目前也已经无法获得是一个事实<img src="https://img.haomeiwen.com/i11473451/de1543d04208b8d9.png" data-ratio="1" data-type="xmt-emoji" data-w="19" style="display:inline-block;width:20px;vertical-align:text-bottom;" />,允悲。<p><span style="color: #8d8d8d;">硬核 | 全国QQ用户24h实时在线人数的爬取与分析,附数据</span></p></span></p><p style="text-align: left;"><span style="text-align: center;"><br /></span></p><p style="text-align: center;"><img class="rich_pages" data-backh="487" data-backw="622" data-before-oversubscription-url="https://mmbiz.qpic.cn/mmbiz_png/7hTk8jdpAdqQZyGMv79Klt5K4dzDhXq2Vd4f5wVD9kiafttJIWOAFZGbbeJsrANyEZo3Bia3SGPHqrKhrJicBkJLA/?wx_fmt=png" data-ratio="0.7828335056876939" data-s="300,640" src="https://img.haomeiwen.com/i11473451/62f1009ffdff2274" data-type="png" data-w="967" style="width: 100%;height: auto;"></p><p style="text-align: left;"><span style="text-align: left;"><br /></span></p><p style="text-align: left;"><span style="text-align: left;">具体的数据获取就不详细说了,比较简单,先抓包分析发现数据接口,再分析数据进行清洗成自己想要的格式:</span></p><p style="text-align: left;"><span style="text-align: left;"><br /></span></p><p style="text-align: center;"><img class="rich_pages" data-ratio="0.5060901339829477" data-s="300,640" src="https://img.haomeiwen.com/i11473451/1279f864b70837a7" data-type="png" data-w="1642" style=""></p><p style="text-align: center;"><img class="rich_pages" data-ratio="0.5230312035661219" data-s="300,640" src="https://img.haomeiwen.com/i11473451/b9cc921fb072fd62" data-type="png" data-w="673" style=""></p><p style="text-align: center;"><br /></p><p style="text-align: left;"><span style="text-align: left;"></span></p><p style="text-align: left;"><span style="text-align: left;">数据的爬取比较简单,没有什么反爬虫措施,</span>也不用设置什么参数,以下代码可以直接用:</p><p style="text-align: left;"><br /></p><p style="text-align: center;"><img class="rich_pages" data-ratio="0.7513157894736842" data-s="300,640" src="https://img.haomeiwen.com/i11473451/1be140d6fd62bd5d" data-type="png" data-w="760"></p><p><br /></p><p>爬取到的数据格式如下,第一列为纬度,第二列为经度,第三列为车辆(使用了高德地图服务的车辆)的定位次数:</p><p><br /></p><p style="text-align: center;"><img class="rich_pages" data-backh="235" data-backw="339" data-before-oversubscription-url="https://mmbiz.qlogo.cn/mmbiz_png/7hTk8jdpAdofga6bGXo0fWrHicsRbQrRrdDIchYL6GhB2ibGcTibPH8p5uVYctLicdRI6joXLhmicO9jJnwGuHqpVmg/0?wx_fmt=png" data-ratio="0.6932153392330384" data-s="300,640" src="https://img.haomeiwen.com/i11473451/8d3d8d39b4882a62" data-type="png" data-w="339" style="width: 100%;height: auto;"></p><p><br /></p><p>之后数据简单的先导入ArcGIS进行转为shp,然后在地图上进行显示,可以看到点要素基本上数据都是沿着道路分布(估计数据主要是用了高德地图车辆导航数据):</p><p><br /></p><p><img class="rich_pages" data-ratio="0.5891195418754474" data-s="300,640" src="https://img.haomeiwen.com/i11473451/4001bf836ae379aa" data-type="png" data-w="1397" style="text-align: center;white-space: normal;"></p><p><img class="rich_pages" data-ratio="0.7385398981324278" data-s="300,640" src="https://img.haomeiwen.com/i11473451/1bc464c0edf6af63" data-type="png" data-w="1178" style="text-align: center;white-space: normal;"></p><section class="xmt-style-block" data-style-type="5" data-tools="新媒体排版" data-id="2154548"><section class="KolEditor" style="border-width: 0px;border-style: none;border-color: initial;padding: 0px;margin-top: 20px;"><section style="border-width: 0px;border-style: none;border-color: initial;"><section style="text-align: center;white-space: normal;"><p style="color:#f05454;" class="active brush">使用高德交通大数据的相关论文推荐</p></section><p style="text-align: center;white-space: normal;"><img class="" data-ratio="0.05555555555555555" src="https://img.haomeiwen.com/i11473451/c87894db3f4712a6" data-type="png" data-w="180"></p></section></section></section><section class="xmt-style-block" data-style-type="5" data-tools="新媒体排版" data-id="2154549"><section class="KolEditor" style="box-sizing: border-box;border-width: 0px;border-style: none;border-color: initial;padding: 0px;margin-top: 17px;"><section class="active brush" style="margin: 3px auto;padding: 15px;color: rgb(121, 121, 121);line-height: 24px;box-shadow: rgb(170, 170, 170) 0px 0px 3px;border-width: 2px;border-style: solid;border-color: rgb(240, 240, 240);"><p>如果大家想做相关研究给大家推荐一篇论文:</p><p>郭向阳, 穆学青, 明庆忠, 丁正山, 胡美娟. <strong>旅游地快速交通优势度与旅游流强度的空间耦合分析</strong>[J]. 地理研究 , 2019, 38 (5): 1119- 1135. </p></section><section style="display: block;width: 0;height: 0;clear: both;"><br /></section></section><span style="color: rgb(121, 121, 121);"><section class="xmt-style-block" data-style-type="5" data-tools="新媒体排版" data-id="2154549"><span style="color: rgb(121, 121, 121);"><br /></span></section>该论文数据来源部分介绍:</span></section><section class="xmt-style-block" data-style-type="5" data-tools="新媒体排版" data-id="2154549"><span style="color: rgb(121, 121, 121);">快速交通系统方面,高速公路:通车里程源自《云南省统计年鉴2017》,路网密度由测算所得,高速路口及站点数量、区位优势度和换乘便捷度等指标均通过</span><span style="color: rgb(255, 76, 65);"><strong>高德交通大数据</strong></span><span style="color: rgb(121, 121, 121);">、<strong>《中国交通地图册》和《中国公路交通图集》</strong>获取。高速铁路:高速铁路里程和站点距离行政中心距离均通过<strong>高德交通大数据获取</strong>,站点数量和日通行车辆通过“12306铁道部火车票网上订票官网”查询获取。航空运输:机场飞行区等级依据航空民航标准-MH5001-2000《民用机场飞行区技术标准》,机场离行政中心距离通过高德交通地图测算获取,日均旅客吞吐量和日均飞机起降架次均依据中国民用航空局发布的2016年《民航机场生产统计公报》和《云南年鉴2017》计算获取。旅游流方面,主要源自《云南省统计年鉴2017》和2016年云南省16个州市的国民经济与社会发展统计公报。</span></section><p><br /></p><section class="xmt-style-block" data-style-type="5" data-tools="新媒体排版" data-id="2154548"><section class="KolEditor" style="border-width: 0px;border-style: none;border-color: initial;padding: 0px;margin-top: 20px;"><section style="border-width: 0px;border-style: none;border-color: initial;"><section style="text-align: center;white-space: normal;"><p style="color:#f05454;" class="active brush">QGIS可视化</p></section><p style="text-align: center;white-space: normal;"><img class="" data-ratio="0.05555555555555555" src="https://img.haomeiwen.com/i11473451/5649423d1cc4572f" data-type="png" data-w="180"></p></section></section></section><p style="white-space: normal;">之前看过张云金老师一篇教程《QGIS教程番外篇02--如何在QGIS中添加自定义的Mapbox底图?》https://mp.weixin.qq.com/s/SzDdQUBVrhwRQ0-bq6J-Nw,感觉很好玩,这次实践一下(点击阅读原文既可以查看完整教程)。</p><p style="white-space: normal;"><br /></p><p style="white-space: normal;text-align: left;"><span style="font-size: 16px;letter-spacing: 0.544px;background-color: rgb(255, 255, 255);">MapBox(我觉得是目前市面上做地图</span><span style="background-color: rgb(255, 255, 255);font-size: 16px;letter-spacing: 0.544px;">最好看的</span><span style="background-color: rgb(255, 255, 255);font-size: 16px;letter-spacing: 0.544px;">厂商)推出的这款地图设计网站网址是https://apps.mapbox.com/cartogram,最好玩的一点就是允许用户上传图片进行地图样式设计(左下角自定义图片)。</span></p><section class="xmt-style-block" data-style-type="5" data-tools="新媒体排版" data-id="1313774"><section class="KolEditor" style="border-width: 0px;border-style: none;border-color: initial;padding: 0px;margin-top: 20px;"><section style="border-width: initial;border-style: none;border-color: initial;margin-bottom: 0.5em;"><section style="height: 2em;display: inline-block;font-size: 1em;font-family: inherit;font-weight: inherit;text-align: center;text-decoration: inherit;border-color: rgb(102, 102, 103);color: inherit;display:flex;"><section style="padding-right: 0.3em;padding-left: 0.3em;height: 2em;line-height: 2em;display: inline-block;vertical-align: top;border-top-width: 0.1em;border-bottom-width: 0.1em;border-left-width: 0.1em;border-style: solid none solid solid;overflow: hidden;border-color:#fff10c;color: inherit;display: flex;"><p class="active brush" style="color:rgb(121,121,121);min-width:1em;">比如一个小皇帝的图片</p></section><section style="display: inline-block;vertical-align: top;height: 2em;border-bottom-width: 0.1em;border-bottom-style: solid;border-right-width: 0.1em;border-right-style: solid;margin-left: -0.6em;width: 1.2em;-webkit-transform: skew(30deg);border-color: #fff10c;color: inherit;"></section><section style="width: 0px;display: inline-block;vertical-align: middle;margin: 0em;border-top-width: 1.8em;border-top-style: solid;border-top-color: #fff10c;border-bottom-color: #fff10c;color: inherit;border-left-width: 1em !important;border-left-style: solid !important;border-left-color: transparent !important;border-right-width: 1em !important;border-right-style: solid !important;border-right-color: transparent !important;"></section></section><section style="width: 0px;height: 0px;clear: both;color: inherit;"></section></section></section></section><p style="text-align: center;"><img class="rich_pages" data-backh="464" data-backw="603" data-before-oversubscription-url="https://mmbiz.qpic.cn/mmbiz_jpg/7hTk8jdpAdofga6bGXo0fWrHicsRbQrRr74GBbxgp7zS57xdnbuLgjIWxtHbJibFr19hazkPu43aQnic0a1iaibNDTg/?wx_fmt=jpeg" data-ratio="0.7691069991954947" data-s="300,640" src="https://img.haomeiwen.com/i11473451/bc1f7f66e738e26f" data-type="jpeg" data-w="1243" style="width: 100%;height: auto;"></p><section class="xmt-style-block" data-style-type="5" data-tools="新媒体排版" data-id="1313774"><section class="KolEditor" style="border-width: 0px;border-style: none;border-color: initial;padding: 0px;margin-top: 20px;"><section style="border-width: initial;border-style: none;border-color: initial;margin-bottom: 0.5em;"><section style="height: 2em;display: inline-block;font-size: 1em;font-family: inherit;font-weight: inherit;text-align: center;text-decoration: inherit;border-color: rgb(102, 102, 103);color: inherit;display:flex;"><section style="padding-right: 0.3em;padding-left: 0.3em;height: 2em;line-height: 2em;display: inline-block;vertical-align: top;border-top-width: 0.1em;border-bottom-width: 0.1em;border-left-width: 0.1em;border-style: solid none solid solid;overflow: hidden;border-color:#fff10c;color: inherit;display: flex;"><p class="active brush" style="color:rgb(121,121,121);min-width:1em;">高德地图交通大数据的截图</p></section><section style="display: inline-block;vertical-align: top;height: 2em;border-bottom-width: 0.1em;border-bottom-style: solid;border-right-width: 0.1em;border-right-style: solid;margin-left: -0.6em;width: 1.2em;-webkit-transform: skew(30deg);border-color: #fff10c;color: inherit;"></section><section style="width: 0px;display: inline-block;vertical-align: middle;margin: 0em;border-top-width: 1.8em;border-top-style: solid;border-top-color: #fff10c;border-bottom-color: #fff10c;color: inherit;border-left-width: 1em !important;border-left-style: solid !important;border-left-color: transparent !important;border-right-width: 1em !important;border-right-style: solid !important;border-right-color: transparent !important;"></section></section><section style="width: 0px;height: 0px;clear: both;color: inherit;"></section></section></section></section><p style="text-align: center;"><img class="rich_pages" data-backh="401" data-backw="644" data-before-oversubscription-url="https://mmbiz.qpic.cn/mmbiz_jpg/7hTk8jdpAdofga6bGXo0fWrHicsRbQrRrlRv82iaIXM7K0QujTgWiczX3mHgIrnJvZe9qHLUMyCEnJ3zUsVWbCVWQ/?wx_fmt=jpeg" data-ratio="0.6234375" data-s="300,640" src="https://img.haomeiwen.com/i11473451/3c8c2a38e18c9249" data-type="jpeg" data-w="1280" style="width: 100%;height: auto;"></p><section class="xmt-style-block" data-style-type="5" data-tools="新媒体排版" data-id="1313774"><section class="KolEditor" style="border-width: 0px;border-style: none;border-color: initial;padding: 0px;margin-top: 20px;"><section style="border-width: initial;border-style: none;border-color: initial;margin-bottom: 0.5em;"><section style="height: 2em;display: inline-block;font-size: 1em;font-family: inherit;font-weight: inherit;text-align: center;text-decoration: inherit;border-color: rgb(102, 102, 103);color: inherit;display:flex;"><section style="padding-right: 0.3em;padding-left: 0.3em;height: 2em;line-height: 2em;display: inline-block;vertical-align: top;border-top-width: 0.1em;border-bottom-width: 0.1em;border-left-width: 0.1em;border-style: solid none solid solid;overflow: hidden;border-color:#fff10c;color: inherit;display: flex;"><p class="active brush" style="color:rgb(121,121,121);min-width:1em;">QQ群二维码</p></section><section style="display: inline-block;vertical-align: top;height: 2em;border-bottom-width: 0.1em;border-bottom-style: solid;border-right-width: 0.1em;border-right-style: solid;margin-left: -0.6em;width: 1.2em;-webkit-transform: skew(30deg);border-color: #fff10c;color: inherit;"></section><section style="width: 0px;display: inline-block;vertical-align: middle;margin: 0em;border-top-width: 1.8em;border-top-style: solid;border-top-color: #fff10c;border-bottom-color: #fff10c;color: inherit;border-left-width: 1em !important;border-left-style: solid !important;border-left-color: transparent !important;border-right-width: 1em !important;border-right-style: solid !important;border-right-color: transparent !important;"></section></section><section style="width: 0px;height: 0px;clear: both;color: inherit;"></section></section></section></section><p style="text-align: center;"><img class="rich_pages" data-ratio="0.7015625" data-s="300,640" src="https://img.haomeiwen.com/i11473451/8b1f381b30af45e7" data-type="jpeg" data-w="1280" style=""></p><p style="white-space: normal;"><br /></p><p style="white-space: normal;">选择好自己想要的地图之后发不成WMTS服务,然后复制链接,即可加载到QGIS上作为底图:</p><p style="white-space: normal;"><img class="rich_pages" data-ratio="0.66484375" data-s="300,640" src="https://img.haomeiwen.com/i11473451/e63217972934fc23" data-type="jpeg" data-w="1280" style="text-align: center;white-space: normal;"></p><p style="text-align: center;"><br /></p><p style="text-align: left;">比如红色作为底图(如下图),或者蓝色灰色等等都可以,看你自己选择:</p><p style="text-align: center;"><img class="rich_pages" data-ratio="0.6219602063375093" data-s="300,640" src="https://img.haomeiwen.com/i11473451/3a6716b39bb46f7a" data-type="png" data-w="1357" style=""></p><section class="xmt-style-block" data-style-type="5" data-tools="新媒体排版" data-id="2154548"><section class="KolEditor" style="border-width: 0px;border-style: none;border-color: initial;padding: 0px;margin-top: 20px;"><section style="border-width: 0px;border-style: none;border-color: initial;"><section style="text-align: center;white-space: normal;"><p style="color:#f05454;" class="active brush">一口气实现数据爬取与可视化</p></section><p style="text-align: center;white-space: normal;"><img class="" data-ratio="0.05555555555555555" src="https://img.haomeiwen.com/i11473451/015ab549cbdc42c5" data-type="png" data-w="180"></p></section></section></section><p>以上所说都是借助软件实现的,那么能不能在爬虫的时候直接就给制作出可视化地图呢?答案当然是可以的,R语言和Python都提供了很多地图可视化的第三方库,比如Python的folium库和pyecharts库都可以很方便的实现地图各种可视化。</p><p><br /></p><p>folium是js上著名的地理信息可视化库leaflet.js为Python提供的接口,通过它我们可以通过在Python端编写代码操纵数据,来调用leaflet的相关功能,基于内建的osm或自行获取的osm资源和地图原件进行地理信息内容的可视化,以及制作优美的可交互地图,今天我就以forlium为例来简单介绍下如何实现高的交通大数据爬取与热力图可视化。</p><p><br /></p><p>以下便是简单的一口气实现数据爬取和可视化代码,非常简单快速,根本不用像导入arcgis然后加载在线地图并且核密度分析啥的那样那么复杂。用代码的话在爬取到数据的同时只要定义好输入的经纬度啥的,直接运行就能展现出非常漂亮的热力图(会生成一个html文件,并且自动在浏览器打开):</p><section class="code-snippet__fix code-snippet__js"><ul class="code-snippet__line-index code-snippet__js"><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul><pre class="code-snippet__js" data-lang="python"><code><span class="code-snippet_outer"><span class="code-snippet__keyword">import</span> requests</span></code><code><span class="code-snippet_outer"><span class="code-snippet__keyword">import</span> pandas <span class="code-snippet__keyword">as</span> pd</span></code><code><span class="code-snippet_outer"><span class="code-snippet__keyword">import</span> time</span></code><code><span class="code-snippet_outer"><span class="code-snippet__keyword">import</span> numpy <span class="code-snippet__keyword">as</span> np</span></code><code><span class="code-snippet_outer"><span class="code-snippet__keyword">import</span> folium</span></code><code><span class="code-snippet_outer"><span class="code-snippet__keyword">import</span> webbrowser</span></code><code><span class="code-snippet_outer"><span class="code-snippet__keyword">from</span> folium.plugins <span class="code-snippet__keyword">import</span> HeatMap</span></code><code><span class="code-snippet_outer"><br /></span></code><code><span class="code-snippet_outer"><span class="code-snippet__function"><span class="code-snippet__keyword">def</span> <span class="code-snippet__title">get_GaoDeData</span><span class="code-snippet__params">()</span>:</span></span></code><code><span class="code-snippet_outer"> url=<span class="code-snippet__string">'https://trp.autonavi.com/assets/data/data2.txt'</span></span></code><code><span class="code-snippet_outer"> response=requests.get(url)</span></code><code><span class="code-snippet_outer"> datas=response.text</span></code><code><span class="code-snippet_outer"> count=datas.split(<span class="code-snippet__string">"&"</span>)</span></code><code><span class="code-snippet_outer"> print(len(count))</span></code><code><span class="code-snippet_outer"> temp=[]</span></code><code><span class="code-snippet_outer"> <span class="code-snippet__keyword">for</span> i <span class="code-snippet__keyword">in</span> range(len(count)<span class="code-snippet__number">-1</span>):</span></code><code><span class="code-snippet_outer"> wzy=count[i].split(<span class="code-snippet__string">","</span>)</span></code><code><span class="code-snippet_outer"> x=float(wzy[<span class="code-snippet__number">0</span>])</span></code><code><span class="code-snippet_outer"> y=float(wzy[<span class="code-snippet__number">1</span>])</span></code><code><span class="code-snippet_outer"> z=int(wzy[<span class="code-snippet__number">2</span>])</span></code><code><span class="code-snippet_outer"> temp.append([x,y,z])</span></code><code><span class="code-snippet_outer"> </span></code><code><span class="code-snippet_outer"> map_osm = folium.Map(location=[<span class="code-snippet__number">35</span>,<span class="code-snippet__number">110</span>],zoom_start=<span class="code-snippet__number">6</span>) <span class="code-snippet__comment">#绘制Map,开始缩放程度是5倍</span></span></code><code><span class="code-snippet_outer"> HeatMap(temp).add_to(map_osm) <span class="code-snippet__comment"># 将热力图添加到前面建立的map里</span></span></code><code><span class="code-snippet_outer"> file_path = <span class="code-snippet__string">r"高德交通大数据地图可视化.html"</span></span></code><code><span class="code-snippet_outer"> map_osm.save(file_path) <span class="code-snippet__comment"># 保存为html文件</span></span></code><code><span class="code-snippet_outer"> webbrowser.open(file_path) <span class="code-snippet__comment"># 默认浏览器打开</span></span></code><code><span class="code-snippet_outer"> </span></code><code><span class="code-snippet_outer"> df=pd.DataFrame(temp)</span></code><code><span class="code-snippet_outer"> now = time.strftime(<span class="code-snippet__string">"%Y-%m-%d-%H_%M_%S"</span>,time.localtime(time.time()))</span></code><code><span class="code-snippet_outer"> df.to_csv(<span class="code-snippet__string">'GaoDe'</span>+now+<span class="code-snippet__string">'.txt'</span>,mode=<span class="code-snippet__string">'a'</span>,index = <span class="code-snippet__keyword">False</span>,header=<span class="code-snippet__keyword">None</span>)</span></code><code><span class="code-snippet_outer"><br /></span></code><code><span class="code-snippet_outer"><span class="code-snippet__keyword">if</span> name ==<span class="code-snippet__string">'main'</span>:</span></code><code><span class="code-snippet_outer"> get_GaoDeData()</span></code><code><span class="code-snippet_outer"> </span></code></pre></section><p style="text-align: center;"><img class="rich_pages" data-ratio="0.6734375" data-s="300,640" src="https://img.haomeiwen.com/i11473451/7e62759a8fed0247" data-type="png" data-w="1280" style=""></p><p style="text-align: center;"><img class="rich_pages" data-ratio="0.7074380165289256" data-s="300,640" src="https://img.haomeiwen.com/i11473451/8c11896ba4b41dfd" data-type="png" data-w="1210" style=""></p><p>当然大家还可以先爬取数据,然后借助第三方地图可视化平台,比如什么地图慧、高德地图和百度地图,都可以实现导入数据进行地图数据展示,但是那样也比较麻烦,所以还是推荐这种<strong>一步到位</strong>的方法。<br /></p><section class="xmt-style-block" data-style-type="5" data-tools="新媒体排版" data-id="2154548"><section class="KolEditor" style="border-width: 0px;border-style: none;border-color: initial;padding: 0px;margin-top: 20px;"><section style="border-width: 0px;border-style: none;border-color: initial;"><section style="text-align: center;white-space: normal;"><p style="color:#f05454;" class="active brush">互联网地理大数据挖掘</p></section><p style="text-align: center;white-space: normal;"><img class="" data-ratio="0.05555555555555555" src="https://img.haomeiwen.com/i11473451/066ce05d7aca90f4" data-type="png" data-w="180"></p></section></section></section><p>巧妇难为无米之炊,为了方便大家进行相关地理学研究,这段时间我也给大家也介绍了不少的互联网地理大数据(其中QQ在线人数数据接口已经关闭,其他正常):</p><p><br /></p><p style="text-align: center;"><img class="rich_pages" data-backh="879" data-backw="604" data-before-oversubscription-url="https://mmbiz.qlogo.cn/mmbiz_png/7hTk8jdpAdofga6bGXo0fWrHicsRbQrRrRB44MMyLQQZXq1ianVTFJ9gNUibZ0a9IEjQq9gCnSxRpV4YkjEINaYbg/0?wx_fmt=png" data-ratio="1.455298013245033" data-s="300,640" src="https://img.haomeiwen.com/i11473451/cb58c6af41aa29ad" data-type="png" data-w="604" style="width: 100%;height: auto;"></p><p><br /></p><p>以上所有文章所有代码数据我都更新到了互联网地理大数据挖掘群,如果大家对地理大数据感兴趣的话欢迎加群讨论。今天的的数据也于昨日上传到群里,大家可以加群或者公众号回复关键字获取相关数据:</p><section class="xmt-style-block" data-style-type="5" data-tools="新媒体排版" data-id="1313774"><section class="KolEditor" style="border-width: 0px;border-style: none;border-color: initial;padding: 0px;margin-top: 20px;"><section style="border-width: initial;border-style: none;border-color: initial;margin-bottom: 0.5em;"><section style="height: 2em;display: inline-block;font-size: 1em;font-family: inherit;font-weight: inherit;text-align: center;text-decoration: inherit;border-color: rgb(102, 102, 103);color: inherit;display:flex;"><section style="padding-right: 0.3em;padding-left: 0.3em;height: 2em;line-height: 2em;display: inline-block;vertical-align: top;border-top-width: 0.1em;border-bottom-width: 0.1em;border-left-width: 0.1em;border-style: solid none solid solid;overflow: hidden;border-color:#fff10c;color: inherit;display: flex;"><p class="active brush" style="color:rgb(121,121,121);min-width:1em;">加入地理大数据挖掘群</p></section><section style="display: inline-block;vertical-align: top;height: 2em;border-bottom-width: 0.1em;border-bottom-style: solid;border-right-width: 0.1em;border-right-style: solid;margin-left: -0.6em;width: 1.2em;-webkit-transform: skew(30deg);border-color: #fff10c;color: inherit;"></section><section style="width: 0px;display: inline-block;vertical-align: middle;margin: 0em;border-top-width: 1.8em;border-top-style: solid;border-top-color: #fff10c;border-bottom-color: #fff10c;color: inherit;border-left-width: 1em !important;border-left-style: solid !important;border-left-color: transparent !important;border-right-width: 1em !important;border-right-style: solid !important;border-right-color: transparent !important;"></section></section><section style="width: 0px;height: 0px;clear: both;color: inherit;"></section></section></section></section><p style="text-align: center;"><img class="rich_pages" data-ratio="0.8069738480697385" data-s="300,640" src="https://img.haomeiwen.com/i11473451/131a4c842eb24914" data-type="png" data-w="803" style=""></p><p style="text-align: left;">群号:<strong>575325764</strong>,验证信息填写<strong>GIS大师兄</strong>。</p><section class="xmt-style-block" data-style-type="5" data-tools="新媒体排版" data-id="1313774"><section class="KolEditor" style="border-width: 0px;border-style: none;border-color: initial;padding: 0px;margin-top: 20px;"><section style="border-width: initial;border-style: none;border-color: initial;margin-bottom: 0.5em;"><section style="height: 2em;display: inline-block;font-size: 1em;font-family: inherit;font-weight: inherit;text-align: center;text-decoration: inherit;border-color: rgb(102, 102, 103);color: inherit;display:flex;"><section style="padding-right: 0.3em;padding-left: 0.3em;height: 2em;line-height: 2em;display: inline-block;vertical-align: top;border-top-width: 0.1em;border-bottom-width: 0.1em;border-left-width: 0.1em;border-style: solid none solid solid;overflow: hidden;border-color:#fff10c;color: inherit;display: flex;"><p class="active brush" style="color:rgb(121,121,121);min-width:1em;">公众号后台回复关键字</p></section><section style="display: inline-block;vertical-align: top;height: 2em;border-bottom-width: 0.1em;border-bottom-style: solid;border-right-width: 0.1em;border-right-style: solid;margin-left: -0.6em;width: 1.2em;-webkit-transform: skew(30deg);border-color: #fff10c;color: inherit;"></section><section style="width: 0px;display: inline-block;vertical-align: middle;margin: 0em;border-top-width: 1.8em;border-top-style: solid;border-top-color: #fff10c;border-bottom-color: #fff10c;color: inherit;border-left-width: 1em !important;border-left-style: solid !important;border-left-color: transparent !important;border-right-width: 1em !important;border-right-style: solid !important;border-right-color: transparent !important;"></section></section><section style="width: 0px;height: 0px;clear: both;color: inherit;"></section></section></section></section><p style="text-align: left;"><span style="font-size: 16px;">公众号回复</span><span style="font-size: 16px;">关键字</span><strong style="font-size: 16px;">高德交通大数据</strong><span style="font-size: 16px;">即可获取以上所有相关高德地图交通大数据原始数据和处理成shp文件的高德交通大数据等。</span></p><p style="text-align: center;"><img class="rich_pages" data-ratio="0.4743801652892562" data-s="300,640" src="https://img.haomeiwen.com/i11473451/5449466a7d01e2aa" data-type="png" data-w="605" style=""></p><section class="xmt-style-block" data-style-type="5" data-tools="新媒体排版" data-id="2113359"><section data-role="outer" label="Powered by 135editor.com" style="font-size: 16px;white-space: normal;" class=""><section class="" data-tools="135编辑器" data-id="93039"><section class=""><section style="margin-top: 10px;margin-bottom: 10px;text-align: center;box-sizing: border-box;"><section style="display: inline-block;width: 50px;height: 60px;vertical-align: top;overflow: hidden;;background-position: 50% 50%;background-repeat: no-repeat;background-size: contain;background-attachment: scroll;box-sizing: border-box;"><section style="margin-top: 18px;text-align: left;box-sizing: border-box;"><section style="text-align: center;font-size: 14px;color: rgb(79, 79, 79);box-sizing: border-box;"><p style="box-sizing: border-box;"><em style="box-sizing: border-box;"><strong style="box-sizing: border-box;"><span style="font-family: PingFangTC-ultralight;box-sizing: border-box;">End</span></strong></em></p></section></section></section></section></section></section></section><p style="font-size: 16px;white-space: normal;" class="">后记:马上我们要上线地理大数据咨询服务,感兴趣的朋友可以加小师妹微信私聊。</p><p style="font-size: 16px;white-space: normal;" class=""><img class="rich_pages" data-copyright="0" data-ratio="0.4255555555555556" data-s="300,640" src="https://img.haomeiwen.com/i11473451/4b6ecb20c5e61d14" data-type="jpeg" data-w="900" style="text-align: center;width: 677px !important;height: auto !important;visibility: visible !important;"></p><section style="font-size: 16px;white-space: normal;box-sizing: border-box;" class=""><section powered-by="xiumi.us" style="box-sizing: border-box;"><section style="margin-top: 20px;margin-bottom: 15px;box-sizing: border-box;"><section style="padding-right: 5px;padding-left: 5px;font-size: 15px;color: rgb(7, 7, 7);line-height: 1.8;letter-spacing: 1px;box-sizing: border-box;"><p class="" style="margin-right: 16px;margin-left: 16px;text-indent: 0em;letter-spacing: 0.544px;text-align: center;background-color: rgb(255, 255, 255);max-width: 100%;min-height: 1em;font-size: 16px;color: rgb(62, 62, 62);font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", "Apple Color Emoji", "Emoji Symbols Font", "Segoe UI Symbol", Arial, sans-serif;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;color: rgb(2, 30, 170);box-sizing: border-box !important;word-wrap: break-word !important;"><strong style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;">「硬核系列文章汇总」</strong></span></p><p class="" style="margin-right: 16px;margin-left: 16px;text-indent: 0em;letter-spacing: 0.544px;text-align: center;background-color: rgb(255, 255, 255);max-width: 100%;min-height: 1em;font-size: 16px;color: rgb(62, 62, 62);font-family: "Helvetica Neue", Helvetica, "Hiragino Sans GB", "Microsoft YaHei", "Apple Color Emoji", "Emoji Symbols Font", "Segoe UI Symbol", Arial, sans-serif;box-sizing: border-box !important;word-wrap: break-word !important;"><span style="max-width: 100%;color: rgb(2, 30, 170);box-sizing: border-box !important;word-wrap: break-word !important;"><strong style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;"><br /></strong></span></p><p style="margin-right: 16px;margin-left: 16px;text-indent: 0em;letter-spacing: 0.544px;background-color: rgb(255, 255, 255);max-width: 100%;box-sizing: border-box;min-height: 1em;font-size: 16px;text-align: left;word-wrap: break-word !important;" class=""><span style="max-width: 100%;font-size: 14px;color: rgb(0, 128, 255);box-sizing: border-box !important;word-wrap: break-word !important;">1.<p><span style="color: #8d8d8d;">硬核 | Python多线程爬取摩拜单车数据与ArcGIS可视化</span></p></span></p><p style="margin-right: 16px;margin-left: 16px;text-indent: 0em;letter-spacing: 0.544px;background-color: rgb(255, 255, 255);max-width: 100%;box-sizing: border-box;min-height: 1em;text-align: left;word-wrap: break-word !important;" class=""><span style="max-width: 100%;box-sizing: border-box;font-size: 14px;color: rgb(0, 128, 255);word-wrap: break-word !important;">2.<p><span style="color: #8d8d8d;">硬核 | 全国QQ用户24h实时在线人数的爬取与分析,附数据</span></p></span></p><p style="margin-right: 16px;margin-left: 16px;text-indent: 0em;letter-spacing: 0.544px;background-color: rgb(255, 255, 255);max-width: 100%;box-sizing: border-box;min-height: 1em;text-align: left;word-wrap: break-word !important;" class=""><span style="max-width: 100%;box-sizing: border-box;font-size: 14px;color: rgb(0, 128, 255);word-wrap: break-word !important;">3.<p><span style="color: #8d8d8d;">硬核 | 利用Python爬取全国250m精度的人口数据(GeoQ)、房价数据和公交站(线路)等数据</span></p></span></p><p style="margin-right: 16px;margin-left: 16px;text-indent: 0em;letter-spacing: 0.544px;background-color: rgb(255, 255, 255);max-width: 100%;box-sizing: border-box;min-height: 1em;text-align: left;word-wrap: break-word !important;" class=""><span style="max-width: 100%;box-sizing: border-box;font-size: 14px;color: rgb(0, 128, 255);word-wrap: break-word !important;">4.<p><span style="color: #8d8d8d;">硬核 | 基于腾讯位置大数据平台的全球移动定位数据爬取</span></p><br style="max-width: 100%;box-sizing: border-box !important;word-wrap: break-word !important;" /></span></p><p style="margin-right: 16px;margin-left: 16px;text-indent: 0em;letter-spacing: 0.544px;background-color: rgb(255, 255, 255);max-width: 100%;box-sizing: border-box;min-height: 1em;text-align: left;word-wrap: break-word !important;" class=""><span style="max-width: 100%;font-size: 14px;color: rgb(0, 128, 255);box-sizing: border-box !important;word-wrap: break-word !important;">5.<p><span style="color: #8d8d8d;">腾讯位置大数据爬取报错的解决办法</span></p></span></p><p style="text-align: center;"><img class="rich_pages" data-ratio="1.2671875" data-s="300,640" src="https://img.haomeiwen.com/i11473451/c981cd0163df6f5e" data-type="jpeg" data-w="1280" style="width: 677px !important;height: auto !important;visibility: visible !important;"></p><p style="text-align: center;"><img class="" data-backh="168" data-backw="569" data-before-oversubscription-url="https://mmbiz.qlogo.cn/mmbiz_png/7hTk8jdpAdofga6bGXo0fWrHicsRbQrRrwiaSOHBoLV0huuDsIzv4zuNqPxice3XFh8drA3BWUAkW1LFEUUbMVnRQ/0?wx_fmt=png" data-ratio="0.29525483304042177" src="https://img.haomeiwen.com/i11473451/e88b1bcf361f5be9" data-type="png" data-w="569" style="color: rgb(51, 51, 51);font-size: 17px;text-align: justify;width: 100%;" title="1431055447872026630.png"><br /></p><p style="text-align: right;"><p><span style="color: #8d8d8d;">点我留言</span></p></p></section></section></section></section></section><section class="xmt-style-block" data-style-type="5" data-tools="新媒体排版" data-id="2009393"><section class="KolEditor" style="margin-top:20px;"><br /></section></section>

    相关文章

      网友评论

        本文标题:硬核 | 高德交通大数据爬取与Python可视化(含数据分享)

        本文链接:https://www.haomeiwen.com/subject/pckxxctx.html