def DrawShapeFile(area):
"""
??????shp??
:param area: ??shp???????????????
:return:
"""
try:
shpfile = area.file
border_shape = shapefile.Reader(shpfile)
border = border_shape.shapes()
for b in border:
border_points = b.points
path_data = []
count = 0
for cell in border_points:
if count == 0:
trans = (Path.MOVETO, (cell[0], cell[1]))
path_data += [trans]
cell_end = cell
else:
trans = (Path.CURVE4, (cell[0], cell[1]))
path_data += [trans]
trans = (Path.CLOSEPOLY, (cell_end[0], cell_end[1]))
path_data += [trans]
codes, verts = zip(*path_data)
path = Path(verts, codes)
x, y = zip(*path.vertices)
plt.plot(x, y, 'k-', linewidth=area.linewidth, color=area.linecolor)
except Exception as err:
print(u'?{0}?{1}-{2}'.format(area['file'], err, datetime.now()))
评论列表
文章目录