通过python带来平滑的地图
smoomap的Python项目详细描述
在python环境中制作平滑的地图
或多或少是来自r spatialposition的stewart method的python端口 包(https://github.com/Groupe-ElementR/SpatialPosition/)。
允许设置所需的类数并选择离散化方法或 直接设置一些自定义打断值。
输入/输出可以是地理层(geojson、shp等)或geodataframe的路径。
需要:
- 纽比
- 土峰达斯
- Matplotlib文件
用法示例:
一次性功能
>>>result=quick_stewart('nuts3_data.geojson',"pop1999",span=65000,beta=3,resolution=48000,mask='nuts3_data.geojson',nb_class=10,user_defined_breaks=None,output="geojson")
面向对象的api,允许使用新的断点值轻松重绘轮廓
>>>StePot=SmoothStewart('nuts3_data.geojson',"pop1999",span=65000,beta=3,resolution=60000,mask='nuts3_data.geojson')>>>res=StePot.render(nb_class=8,disc_func="jenks",output="GeoDataFrame")>>>res.plot(cmap="YlOrRd",linewidth=0.1)
计算的长部分是在初始化 SmoothStewart实例(即实际计算潜力)。一些 方便的方法允许调整和重新导出最后几个步骤:
允许使用新的分类方法快速重绘多边形
可用分类 方法有:“等间隔”、“prog-geom”、“jenks”、“百分位数”和 “头尾骨折”
>>>res=StePot.render(nb_class=6,disc_func="percentiles",output="GeoDataFrame")
允许设置自定义中断值(强烈建议在第一个 渲染或查看分布):
>>>my_breaks=[0,1697631,3395263,5092894,6790526,8488157,10185789,11883420,13581052]>>>res=StePot.render(nb_class=6,user_defined_breaks=my_breaks,output="GeoDataFrame")
安装:
来自PYPI:
$ pip install smoomapy
来自Github:
$ git clone http://github.com/mthh/smoomapy.git
$ cd smoomapy/
$ python setup.py install