python文件读写用到的库_Python使用pyshp库读取shapefile信息的方法
通過pyshp庫,可以讀寫shapefile文件,查詢相關(guān)信息,github地址為
import shapefile # 使用pyshp庫
file = shapefile.reader("data\\市界.shp")
shapes = file.shapes()
#
print(file.shapetype) # 輸出shp類型
'''
null = 0
point = 1
polyline = 3
polygon = 5
multipoint = 8
pointz = 11
polylinez = 13
polygonz = 15
multipointz = 18
pointm = 21
polylinem = 23
polygonm = 25
multipointm = 28
multipatch = 31
'''
print(file.bbox) # 輸出shp的范圍
#
# print(shapes[1].parts)
# print(len(shapes)) # 輸出要素數(shù)量
# print(file.numrecords) # 輸出要素數(shù)量
# print(file.records()) # 輸出所有屬性表
#
'''
字段類型:此列索引處的數(shù)據(jù)類型。類型可以是:
“c”:字符,文字。
“n”:數(shù)字,帶或不帶小數(shù)。
“f”:浮動(與“n”相同)。
“l(fā)”:邏輯,表示布爾值true / false值。
“d”:日期。
“m”:備忘錄,在gis中沒有意義,而是xbase規(guī)范的一部分。
'''
# fields = file.fields
# print(fields)
#
#
for index in range(len(shapes)):
geometry = shapes[index]
# print(geometry.shapetype)
# print(geometry.points)
#
以上這篇python使用pyshp庫讀取shapefile信息的方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持萬仟網(wǎng)。
如您對本文有疑問或者有任何想說的,請點擊進(jìn)行留言回復(fù),萬千網(wǎng)友為您解惑!
總結(jié)
以上是生活随笔為你收集整理的python文件读写用到的库_Python使用pyshp库读取shapefile信息的方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: b+树时间复杂度_数据结构:线性表,栈,
- 下一篇: arduino 蓝牙示例_Arduino
