更多>>关于我们
西安鲲之鹏网络信息技术有限公司从2010年开始专注于Web(网站)数据抓取领域。致力于为广大中国客户提供准确、快捷的数据采集相关服务。我们采用分布式系统架构,日采集网页数千万。我们拥有海量稳定高匿HTTP代理IP地址池,可以有效获取互联网任何公开可见信息。
您只需告诉我们您想抓取的网站是什么,您感兴趣的字段有哪些,你需要的数据是哪种格式,我们将为您做所有的工作,最后把数据(或程序)交付给你。
数据的格式可以是CSV、JSON、XML、ACCESS、SQLITE、MSSQL、MYSQL等等。
更多>>技术文章
经过鲲之鹏技术人员数天的技术攻关,终于成功从百度地图APP采集到POI的边界数据,并成功进行了坐标数据还原和边界数据验证。下面详细介绍一下。
uid: ba9b506a87e4f43cf32d8314
name: 振业泊公馆
addr: 西安市灞桥区广安路800号
geo: Point [x=12139200, y=4046920]
cityId: 233
tel: (029)83531888
zip: null
nearby: null
geojson:
{"dataset":[{"ud":"ba9b506a87e4f43cf32d8314","ty":33,"nst":60,"fst":0,"of":15,"in":0,"tx":"振业泊公馆","sgeo":{"bound":[12138948,4046770,12139454,4047084],"type":3,"elements":[{"points":[12139329,4047084,99,-203,26,-30,-3,-59,-459,-23,-30,16,-8,26,1,52,-7,131,56,19,4,17,3,53,318,2]}]}}]}
该POI在百度地图APP中的边界截图如下:
下面分析一下返回的GEOJSON数据的含义。
先看下POI的位置坐标参数,如下:
geo: Point [x=12139200, y=4046920]
以前我们曾介绍过,百度地图中使用的是墨卡托平面坐标,详见这里http://www.site-digger.com/html/articles/20150831/98.html。
将[x=12139200, y=4046920]墨卡托坐标转换为经纬度坐标为(109.047102,34.315398),如下图所示。
可以通过坐标拾取系统的坐标反查功能验证一下,如下图所示,位置正确:
再重点看GEOJSON的含义,为了便于查看,JSON数据格式化后如下图所示:
猜测边界信息位于"points"中。但是points数据看起来很奇怪,不是正常的经纬度组。
猜测1,按前后顺序每两个为一组经纬度。
前两个看起来是应该墨卡托坐标,后面的数字很小,而且有负数,很奇怪。
猜测2,从第二组数字起,值为相对于前一组数据的差值。例如第二组数据是(99, -203),真实值应该是(12139329 + 99, 4047084 - 203),即(12139428, 4046881)。
下面验证下上述猜测是否正确。按上述思路将points中的墨卡托坐标对进行修正:
# test.py points = {'points': [12139329, 4047084, 99, -203, 26, -30, -3, -59, -459, -23, -30, 16, -8, 26, 1, 52, -7, 131, 56, 19, 4, 17, 3, 53, 318, 2]} pre_x = None pre_y = None i = 0 while i <= len(points['points']) - 1: x = points['points'][i] y = points['points'][i+1] i += 2 if pre_x is None: pre_x = x pre_y = y print (x, y) else: print (pre_x + x, pre_y + y) pre_x = pre_x + x pre_y = pre_y + y
修正后的13组墨卡托坐标对如下:
[(12139329, 4047084), (12139428, 4046881), (12139454, 4046851), (12139451, 4046792), (12138992, 4046769), (12138962, 4046785), (12138954, 4046811), (12138955, 4046863), (12138948, 4046994), (12139004, 4047013), (12139008, 4047030), (12139011, 4047083), (12139329, 4047085)]
再将其转为经纬度坐标对,如下:
[(109.04826126153179, 34.3166200411101), (109.04915058398667, 34.315106883764116), (109.04938414341926, 34.31488326211714), (109.04935719425397, 34.31444347112423), (109.04523397196317, 34.3142720265479), (109.04496448031017, 34.31439129237754), (109.04489261586937, 34.31458509898596), (109.04490159892448, 34.31497271084807), (109.04483871753878, 34.315949186570386), (109.04534176862437, 34.31609081186824), (109.04537770084477, 34.3162175290356), (109.04540465001007, 34.316612587200495), (109.04826126153179, 34.316627495019034)]
使用百度地图API标注(在线测试http://lbsyun.baidu.com/jsdemo.htm#c2_9),代码如下:
// 百度地图API多边形区域标注 // http://lbsyun.baidu.com/jsdemo.htm#c2_9 var map = new BMap.Map("allmap"); map.centerAndZoom(new BMap.Point(109.047102,34.315398), 15); map.enableScrollWheelZoom(); var polygon = new BMap.Polygon([ new BMap.Point(109.048261262,34.3166200411), new BMap.Point(109.049150584,34.3151068838), new BMap.Point(109.049384143,34.3148832621), new BMap.Point(109.049357194,34.3144434711), new BMap.Point(109.045233972,34.3142720265), new BMap.Point(109.04496448,34.3143912924), new BMap.Point(109.044892616,34.314585099), new BMap.Point(109.044901599,34.3149727108), new BMap.Point(109.044838718,34.3159491866), new BMap.Point(109.045341769,34.3160908119), new BMap.Point(109.045377701,34.316217529), new BMap.Point(109.04540465,34.3166125872), new BMap.Point(109.048261262,34.316627495) ], {strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5}); //创建多边形 map.addOverlay(polygon); //增加多边形
标注效果如下:
和百度地图中查询出来的该小区边界对比一致,如下图。
再找另一个POI验证一遍,从百度地图APP采集到的小区(366581fe3fd52baa714b871e)的基本信息和边界信息如下:
uid: 366581fe3fd52baa714b871e name: 水岸东方-三期 addr: 西安市灞桥区浐河东路与韩森东路交叉路口往东约100米(水岸东方) geo: Point [x=12139965, y=4040335] cityId: 233 tel: zip: null nearby: null geojson: {"dataset":[{"ud":"366581fe3fd52baa714b871e","ty":33,"nst":60,"fst":0,"of":15,"in":0,"tx":"水岸东方-三期","sgeo":{"bound":[12139757,4040117,12140208,4040590],"type":3,"elements":[{"points":[12139783,4040475,270,115,156,-399,-394,-74,-57,334,9,15,16,9]}]}}]}
修正后的墨卡托坐标组:
(12139783, 4040475) (12140053, 4040590) (12140209, 4040191) (12139815, 4040117) (12139758, 4040451) (12139767, 4040466) (12139783, 4040475)
墨卡托转经纬度后:
(109.05234,34.267343) (109.054765,34.2682) (109.056166,34.265224) (109.052627,34.264672) (109.052115,34.267164) (109.052196, 34.267275) (109.05234, 34.267343)
百度地图API标注测试,测试结果截图:
和直接通过百度地图中查询出来的边界是吻合的,如下图所示。
再找一个边界复杂点的小区验证下,从百度地图APP采集到的小区(50fe0b843b8fa7ed0b1cc7b9)的基本信息和GEOJSON数据如下:
uid: 50fe0b843b8fa7ed0b1cc7b9 name: 自然界·云栖 addr: 陕西省西安市灞桥区浐河东路与金桥六路交叉口东北 geo: Point [x=12137930, y=4049163] cityId: 233 tel: zip: null nearby: null geojson: {"dataset":[{"ud":"50fe0b843b8fa7ed0b1cc7b9","ty":33,"nst":60,"fst":0,"of":15,"in":0,"tx":"自然界·云栖","sgeo":{"bound":[12137623,4049016,12138272,4049317],"type":3,"elements":[{"points":[12137623,4049168,25,32,97,64,66,13,19,6,28,20,58,16,45,-4,51,-8,32,-5,27,-18,162,-109,12,-1,27,-25,-84,-78,-101,16,-3,-50,-15,6,-70,7,-73,1,-121,-17,-57,-17,-124,152]}]}}]}
如下图所示,上面是在百度地图中查询出来的“自然界·云栖”小区的边界,下面是我们采集到的边界参数经过API标记后的结果。上下是吻合的。
再来一个边界更复杂的POI:
uid: b68bc691d025fcd81e1d1139 name: 长安大学 addr: 陕西省西安市碑林区二环南路中段126号 geo: Point [x=12129635, y=4036408] cityId: 233 tel: (029)82334085 zip: null nearby: null geojson: {"dataset":[{"ud":"b68bc691d025fcd81e1d1139","ty":33,"nst":60,"fst":0,"of":15,"in":0,"tx":"长安大学","sgeo":{"bound":[12128773,4035966,12130346,4036962],"type":3,"elements":[{"points":[12130011,4036961,0,-80,95,-1,2,-59,89,1,10,-1,4,-1,1,-4,0,-60,36,0,24,-3,75,0,0,-121,-84,0,-1,-40,2,-55,-73,0,0,-46,3,-8,1,-80,-1,-12,0,-14,-2,-9,-1,-11,-30,0,-188,-1,-155,2,1,-41,5,-20,2,-21,2,-154,1,-150,-54,-5,-60,4,-5,1,-4,0,-4,-2,-9,-3,-19,-2,-87,0,-65,2,0,25,-160,-1,-145,-1,-138,-1,-177,-1,-127,-3,0,193,2,5,8,9,61,56,3,2,4,1,80,1,17,2,12,3,7,1,38,-1,26,3,48,8,205,4,236,5,1,38,10,40,4,296,68,-1,39,0,2,12,1,7,1,36,0,32,69,1,-1,70,-56,0,0,28,0,9,1,4,1,5,-1,64,17,0,1,28,151,1,37,0,41,-1,17,0,59,1,0,12,29,0]}]}}]}
如下图所示,上面是百度地图查询结果,下面是我们采集标注的结果。