Matplotlib Toolkits:地图绘制工具

来源:互联网 发布:数据挖掘十大算法书评 编辑:程序博客网 时间:2024/06/11 19:49

Matplotlib Toolkits:地图绘制工具 

有没有一种可以直接在详细地图(如谷歌地图)上绘制上百万坐标点的工具???谷歌地图坐标点多了也不能绘制了。

Basemap

(Not distributed with matplotlib,要手动安装)

Plots data on map projections, with continental and political boundaries, see basemap docs.

安装

先下载anacondaPython 3版本

conda install -c scitools basemap

[Installing¶]

使用

分辨率设置

if resolution == 'c':    area_thresh = 10000.elif resolution == 'l':    area_thresh = 1000.elif resolution == 'i':    area_thresh = 100.elif resolution == 'h':    area_thresh = 10.elif resolution == 'f':    area_thresh = 1.

[basemap]

[地理信息可视化——Python之matplotlib Basemap简介]

[So You’d Like To Make a Map Using Python ]

静态地图示例

# coding=utf8import osimport sysimport matplotlib.pyplot as pltimport pandas as pdCWD = os.path.split(os.path.realpath(__file__))[0]os.makedirs(os.path.join(CWD, 'middlewares'), exist_ok=True)sys.path.append(os.path.join(CWD, '../../..'))df = pd.read_pickle(os.path.join(CWD, 'middlewares/df.pkl'))  # ca datasetsll = df[['longitude', 'latitude']].valuesprint(len(ll))x, y = ll[:, 0], ll[:, 1]from mpl_toolkits.basemap import Basemap# 建一用于制。我使用的是墨托投影,并显示整世界。m = Basemap(projection='merc', llcrnrlat=-50, urcrnrlat=65, llcrnrlon=-165, urcrnrlon=155, lat_ts=20, resolution='c')# 制海岸线,以及地边缘m.drawcoastlines()m.drawmapboundary()m.drawcountries()m.drawstates()m.drawcounties()x, y = m(y, x)m.scatter(x, y, 1, marker='.', color='r')plt.show()

Debug

m.drawcounties() UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf1 in position 2: invalid continuation byte

解决:shapefile.py源码有错:修改编码为latin-1就可以了,也是醉了。。。

return v.decode('latin-1')# return v.decode('utf-8')

[[译]比一比:Python的七个数据可视化工具 静态地图]

皮皮blog


Cartopy

评价:安装麻烦,map功能也不能使用了,估计开发者也抛弃了。。。真是跪了。。。lz已弃用

(Not distributed with matplotlib)

Cartopy is a Python package designed to make drawing maps for data analysis and visualisation as easy as possible.

Cartopy makes use of the powerful PROJ.4, numpy and shapely libraries and has a simple and intuitivedrawing interface to matplotlib for creating publication quality maps.

Some of the key features of cartopy are:

  • object oriented projection definitions
  • point, line, vector, polygon and image transformations between projections
  • integration to expose advanced mapping in matplotlib with a simple and intuitive interface
  • powerful vector data handling by integrating shapefile reading with Shapely capabilities

An alternative mapping library written for matplotlib v1.2 and beyond.Cartopy builds on top ofmatplotlib to provide object oriented map projection definitions and closeintegration with Shapely for powerful yet easy-to-use vector data processingtools.

Note: shapely,是geos的python封装,而geos是jts的c++移植版本。[python地理数据处理库geopy ]

安装

先下载anacondaPython 3版本

conda install -c scitools cartopy

[Installing Cartopy¶]

下载配角:地图数据
下载地址:http://www.naturalearthdata.com/downloads/
里面有三种分辨率的shape地图数据可选,方便起见,分别下载三种分辨率中的physical数据中的Coastline和Land数据,每种数据下载后都是一个压缩包,如下载了1:10分辨率的physical中的coastline数据压缩包:ne_10m_coastline.zip,解压缩后有6个文件,其中“ne_10m_coastline.README”和“ne_10m_coastline.VERSION”可直接删除,剩余4个,进行改名操作,扩展名前面的文件名,如“ne_10m_coastline”,修改为“10m_coastline”,即去掉“ne_”,4个文件分别这样更改。再下载1:50和1:110的文件分别进行此操作。所有地图文件下载、解压、更名完毕后,拷贝到一个文件夹下。我的文件夹列表如下图,把这些文件全选(注意进入文件夹目录,全选文件,不带文件夹),复制粘贴到D:\Program Files\WinPython-32bit-2.7.9.3\settings\.local\share\cartopy\shapefiles\natural_earth\physical 目录下(该目录根据自己所装的python而定,运行(1)中的程序后,程序会自动创建physical文件夹,具体该文件夹在哪,搜索电脑文件找找看),我安装的是winpython2.7.9.3,physical目录就位于上面这个目录中,所以我把所有shape地图文件拷贝到了该physical目录下。

[python绘制地图的利器Cartopy使用说明]

或者下载详细地图:http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_admin_1_states_provinces.zip解压到:c:\Users\《用户》.local\share\cartopy\shapefiles\natural_earth\cultural\

[cartopy_trial]

使用

最近不能使用map服务了:

As of July 11, 2016, direct tile access has been discontinued.Please visit our blog post for more information:http://goo.gl/xB0xXt

[Cartopy]

[examples: Cartopy gallery]

皮皮blog



谷歌地图python接口gmplot

10w以上数据坐标点绘制js就基本崩了不能用了。

Plotting data on Google Maps, the easy way. A matplotlib-likeinterface to generate the HTML and javascript to render all thedata you'd like on top of Google Maps. Several plotting methodsmake creating exploratory map views effortless.

# coding=utf8import osimport sysimport pandas as pdCWD = os.path.split(os.path.realpath(__file__))[0]df = pd.read_pickle(os.path.join(CWD, 'middlewares/df.pkl'))  # ca datasetsll = df[['longitude', 'latitude']].valuesprint(len(ll))x, y = ll[:, 0], ll[:, 1]import gmplotgmap = gmplot.GoogleMapPlotter(37.428, -122.145, 5)# gmap.plot(latitudes, longitudes, 'cornflowerblue', edge_width=10)gmap.scatter(x, y, marker=False, c='r', size=2)# gmap.heatmap(heat_lats, heat_lngs)gmap.draw("map.html")

[gmplot]

高德地图amap python接口

1)读取文件信息,这里用pandas库以dataframe形式.

2)高德地图添加点有50数量限制,所以lz就直接弃用了。。。

3)将查询经纬度后的结果存为csv

[Python获取amap高德地图]

百度地图python接口

[mapapi > 0.2.1]

[python实现地址分布可视化]

[Baidu与Google地图API初探 ]

皮皮blog



其它工具

[使用地图工具,给出经纬度,画出受影响的中国省份,(比如台风经过的path、各省经济问题热点图。。。)]

from: Matplotlib Toolkits:地图绘制工具

ref: [Mapping Toolkits]


0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 发邮箱文件超2g怎么办 报考计算机二级邮箱不存在怎么办 苹果邮箱登录要imap密码怎么办 注销微信支付后怎么办 手机卡注销后支付宝怎么办 12306手机邮箱都换了怎么办 网易手机邮箱手机换了怎么办 崩坏3号被盗了怎么办 qq账号被永久冻结了怎么办 淘宝账号被永久冻结了怎么办 qq账号被永久冻结怎么办 多多理财账号冻结了怎么办 苹果id安全问题忘记了怎么办 网易邮箱帐号忘了怎么办 网易邮箱密码忘记了怎么办 网易邮箱密码忘了怎么办 网易邮箱忘记邮箱账号怎么办 崩坏3三无号被盗怎么办 qq邮箱给58占用怎么办 支付宝邮箱被占用怎么办 苹果手机下载不了qq怎么办 附件预览时发生错误怎么办 手机下载的压缩包打不开怎么办 邮箱提示中转站剩余容量不足怎么办 手机邮箱密码忘记了怎么办 垃圾邮件被系统删除了怎么办 邮箱里的邮件下载不了怎么办 qq邮箱下载不了文件怎么办 苹果手机忘记邮箱密码怎么办 oppo手机安装包损坏怎么办 手机安装包损坏无法安装怎么办 手机qq安装包损坏了怎么办 安装包损坏无法安装怎么办 方舟生存进化安装包损坏怎么办 如果安装包坏了怎么办 酷狗下载音乐收费怎么办 酷狗下载歌曲收费怎么办 酷狗音乐下载歌曲要钱怎么办 酷狗音乐下载要钱怎么办 手机酷狗音乐下载收费怎么办 咪咕视频静音了怎么办