assess_models.py 文件源码

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

项目:groundfailure 作者: usgs 项目源码 文件源码
def convert2Prob(gdict, inventory, mustContainCenter=False):
    """Convert inventory shapefile to binary grid (with geodict of gdict) with 1 if any part of landslide was in a cell, 0 if not

    :param gdict: geodict, likely taken from model to compare inventory against
    :param inventory: full file path to shapefile of inventory, must be in geographic coordinates, WGS84
    :type inventory: string
    :returns rast: Grid2D object containing rasterized version of inventory where cell is 1. if any part of a landslide was in the cell
    """
    with fiona.open(inventory) as f:
        invshp = list(f.items())

    shapes = [shape(inv[1]['geometry']) for inv in invshp]

    # Rasterize with allTouch
    rast = Grid2D.rasterizeFromGeometry(shapes, gdict, fillValue=0., burnValue=1.0, mustContainCenter=mustContainCenter)

    return rast
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号