geopandas 的使用以及相关问题
来源:互联网 发布:网络机房整改方案 编辑:程序博客网 时间:2024/06/06 02:07
geopandas 的使用以及相关问题
Geoff Boeing
Michelle Fullwood
%matplotlib inlineimport pandas as pdimport geopandas as gpdfrom geopandas import GeoDataFrame, read_filefrom geopandas.tools import sjoinfrom shapely.geometry import Point, mapping,shapeimport time
from geopandas.geoseries import Polygonfrom geopandas import GeoSeriesp1 = Polygon([(0, 0), (1, 0), (1, 1)])p2 = Polygon([(0, 0), (1, 0), (1, 1), (0, 1)])p3 = Polygon([(2, 0), (3, 0), (3, 1), (2, 1)])g=GeoSeries([p1,p2,p3])g
0 POLYGON ((0 0, 1 0, 1 1, 0 0))1 POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))2 POLYGON ((2 0, 3 0, 3 1, 2 1, 2 0))dtype: object
g.plot()
g.area
0 0.51 1.02 1.0dtype: float64
g.buffer(1).plot()
boros=GeoDataFrame.from_file(r'D:\下载\nybb_16a\nybb_16a\nybb.shp'.decode('utf-8'))
### IPython 带有中文的路径编码为uft-8,需更改编码为acci编码,win下才能识别。r="D:\下载\nybb_16a\nybb_16a\nybb.shp"import chardetchardet.detect(r)
{‘confidence’: 0.7525, ‘encoding’: ‘utf-8’}boros.set_index('BoroCode',inplace=True)aa=boros.loc[5]['geometry']boros.loc[5]
BoroName Staten IslandShape_Area 1.62382e+09Shape_Leng 330470geometry (POLYGON ((970217.0223999023 145643.3322143555...Name: 5, dtype: object
world=gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))world.crs
{‘init’: u’epsg:4326’}cities = gpd.read_file(gpd.datasets.get_path('naturalearth_cities'))
world.head()
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))cities = gpd.read_file(gpd.datasets.get_path('naturalearth_cities'))world.head()
from geopandas import GeoDataFrame as df# from pandas import DataFrame as dffrom geopandas.geoseries import Pointdf1 = df.set_geometry([Point(0,0), Point(1,1), Point(2,2)])df2 = df.set_geometry('geom1')
-----------------------------------------------------------------------
修改默认的notebook的显示的图片大小
import matplotlib.pylab as pylabimport matplotlib.pyplot as pltpylab.rcParams['figure.figsize'] = 20, 20world.plot()
%matplotlib inlineworld.plot(color='white',figsize=(20, 20))
控制图像 需要认真的研究bokeh 一个Python 交互式的绘图包
import bokehfrom bokeh import mplfrom bokeh.plotting import output_file, showcitys=cities.to_crs(world.crs)# base=world.plot(color='white')# cities.plot(ax=base,color='red',figsize=(100,100))# show(mpl.to_bokeh())
将交互式的画面显示在notebook 中,bokeh教程,实例
from ipywidgets import interactimport numpy as npfrom bokeh.io import push_notebook, show, output_notebookfrom bokeh.plotting import figureoutput_notebook()x = np.linspace(0, 2*np.pi, 2000)y = np.sin(x)p = figure(title="simple line example", plot_height=300, plot_width=600, y_range=(-5,5))r = p.line(x, y, color="#2222aa", line_width=3)def update(f, w=1, A=1, phi=0): if f == "sin": func = np.sin elif f == "cos": func = np.cos elif f == "tan": func = np.tan r.data_source.data['y'] = A * func(w * x + phi) push_notebook()show(p)
0 0
- geopandas 的使用以及相关问题
- RDTSC指令的使用以及相关问题
- SQL函数openrowset()的使用以及相关问题处理。
- Uploadify使用心得以及相关问题搜集
- 虚拟主机wdcp的相关问题以及解决方法
- 自定义Dialog以及Dialog的相关问题
- git以及github冲突相关的问题
- .htaccess 配置以及相关问题的解释
- wmi 局域网的相关问题以及解决方案
- cmd使用cl编译的配置方法以及相关问题的解决方法
- 有关于dmx控制器的相关使用问题以及当中的特点
- Tesseract应用:ScrollView.jar以及ViewDebugging的使用及相关问题
- treegrid使用,以及相关数据的整合
- redis的使用详解以及相关命令
- Git的使用以及相关命令
- Reachability的使用相关问题
- Weka使用的相关问题
- ScrollView中使用Listview,以及相关定位问题
- React Native 切换监听端口(Android)
- D3_函数
- 写一个“标准”宏MIN,这个宏输入两个参数并返回较小的一个?
- 输入框input
- 安卓面试题(1-4)
- geopandas 的使用以及相关问题
- Ubuntu"有线未托管"问题解决
- 互联网巨头亚马逊公司微服务化经验
- Jquery easyui tree
- iOS中的界面渲染性能
- SqlServer
- 【BZOJ4566】找相同字符,后缀数组
- java中几种synchronized用法总结
- 系统设置指令