Map.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:MicapsDataDraw 作者: flashlxy 项目源码 文件源码
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()))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号