当前位置: 首页>>代码示例>>Python>>正文


Python Polygon.basin_id方法代码示例

本文整理汇总了Python中matplotlib.patches.Polygon.basin_id方法的典型用法代码示例。如果您正苦于以下问题:Python Polygon.basin_id方法的具体用法?Python Polygon.basin_id怎么用?Python Polygon.basin_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.patches.Polygon的用法示例。


在下文中一共展示了Polygon.basin_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_features_from_shape

# 需要导入模块: from matplotlib.patches import Polygon [as 别名]
# 或者: from matplotlib.patches.Polygon import basin_id [as 别名]
def get_features_from_shape(basemap, path = 'data/shape/contour_bv_MRCC/Bassins_MRCC_utm18.shp', linewidth = 2,
                        edgecolor = 'k', face_color = "none", id_list = None, zorder = 0, alpha = 1):
    driver = ogr.GetDriverByName("ESRI Shapefile")
    dataStore = driver.Open(path, 0)
    layer = dataStore.GetLayer(0)
    latlong = osr.SpatialReference()
    latlong.ImportFromProj4("+proj=latlong")
    result = []

    id_list_lower = []
    if id_list is not None:
        id_list_lower = map(lambda x: x.lower(), id_list)

    feature = layer.GetNextFeature()
    while feature:
        geom = feature.GetGeometryRef()
        geom.TransformTo(latlong)


        #get fields of the feature
#        for i in xrange(feature.GetFieldCount()):
#            print feature.GetField(i)

#        print geom.ExportToWkt()

        polygon = loads(geom.ExportToWkt())
        boundary = polygon.exterior
        coords = np.zeros(( len(boundary.coords), 2))
        currentId = None
        for i, the_coord in enumerate(boundary.coords):


#            if feature.GetFieldAsString('abr').lower() == 'rdo':
#                print the_coord[0], the_coord[1]
            if basemap is not None:
                coords[i, 0], coords[i, 1] = basemap( the_coord[0], the_coord[1] )

            currentId = feature.GetFieldAsString("abr").lower()

        to_add = True
        if id_list is not None:
            to_add = currentId in id_list_lower

        if to_add:
            p = Polygon(coords,linewidth = linewidth, edgecolor = edgecolor,
                facecolor=face_color, zorder = zorder, alpha = alpha)
            p.basin_id = currentId
            result.append(p)
        feature = layer.GetNextFeature()


    dataStore.Destroy()
    return result
开发者ID:guziy,项目名称:PlotWatrouteData,代码行数:55,代码来源:read_shape_file.py


注:本文中的matplotlib.patches.Polygon.basin_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。