sample.py 文件源码

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

项目:groundfailure 作者: usgs 项目源码 文件源码
def rasterizeShapes(pshapes, geodict, all_touched=True):
    """
    Rastering a shape

    Args:
        pshapes: Sequence of orthographically projected shapes.
        goedict: Mapio geodictionary.
        all_touched: Turn pixel "on" if shape touches pixel, otherwise turn it
            on if the center of the pixel is contained within the shape. Note
            that the footprint of the shape is inflated and the amount of
            inflation depends on the pixel size if all_touched=True.

    Returns:
        Rasterio grid.
    """
    outshape = (geodict.ny, geodict.nx)
    txmin = geodict.xmin - geodict.dx / 2.0
    tymax = geodict.ymax + geodict.dy / 2.0
    transform = Affine.from_gdal(
        txmin, geodict.dx, 0.0, tymax, 0.0, -geodict.dy)
    img = rasterio.features.rasterize(
            pshapes, out_shape=outshape, fill=0.0, transform=transform,
            all_touched=all_touched, default_value=1.0)
    return img
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号