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)) # 输出要素数量
# print(file.numRecords) # 输出要素数量
# print(file.records()) # 输出所有属性表
#
'''
字段类型:此列索引处的数据类型。类型可以是:
“C”:字符,文字。
“N”:数字,带或不带小数。
“F”:浮动(与“N”相同)。
“L”:逻辑,表示布尔值True / False值。
“D”:日期。
“M”:备忘录,在GIS中没有意义,而是xbase规范的一部分。
'''
# fields = file.fields
# print(fields)
#
#
for index in range(len(shapes)):
geometry = shapes[index]
# print(geometry.shapeType)
# print(geometry.points)
#
转载自:https://blog.csdn.net/GISuuser/article/details/81664223