【582】QGIS 矢量化 & Python 加载 shapefile

参考:QGIS创建矢量文件以及特殊矢量图形的画法

参考:Python 的一些练习(1)加载shapefile


一、QGIS 矢量化 (MAC)

  • Layer -> Create Layer -> New Shapefile Layer...
  • 选择存储位置、选择绘制的 shp 类型

二、Python 加载 shapefile 文件

import shapely, geopandas
tpath = 'D:/shapefile/province.shp'
 
shp_df = geopandas.GeoDataFrame.from_file(tpath,encoding = 'gb18030')

shp_df.head()    # 获取表头
shp_df.plot()

  输出:

	id	geometry
0	0	POLYGON ((-1.41816 0.82393, -0.98349 0.81018, ...
1	1	POLYGON ((-0.39477 0.82118, 0.27923 0.77717, 0...
2	2	POLYGON ((0.75791 0.55708, 1.26135 0.39752, 1....
3	3	POLYGON ((-0.96974 0.21320, -0.24897 0.16094, ...
  • 每一个 geometry 类记录了一个 polygon 的 shapely 格式的文件
  • 通过 shapely polygon 可以进行其他操作了 

  

原文地址:https://www.cnblogs.com/alex-bn-lee/p/14946174.html