protobufcodecs.py 文件源码

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

项目:geopyspark 作者: locationtech-labs 项目源码 文件源码
def from_pb_tile(tile, no_data_value=None, data_type=None):
    """Creates a ``Tile`` from ``ProtoTile``.

    Args:
        tile (ProtoTile): The ``ProtoTile`` instance to be converted.

    Returns:
        :class:`~geopyspark.geotrellis.Tile`
    """

    if not data_type:
        data_type = _mapped_data_types[tile.cellType.dataType]

    if data_type == 'BIT':
        cells = np.int8(tile.uint32Cells[:])
    elif data_type == 'BYTE':
        cells = np.int8(tile.sint32Cells[:])
    elif data_type == 'UBYTE':
        cells = np.uint8(tile.uint32Cells[:])
    elif data_type == 'SHORT':
        cells = np.int16(tile.sint32Cells[:])
    elif data_type == 'USHORT':
        cells = np.uint16(tile.uint32Cells[:])
    elif data_type == 'INT':
        cells = np.int32(tile.sint32Cells[:])
    elif data_type == 'FLOAT':
        cells = np.float32(tile.floatCells[:])
    else:
        cells = np.double(tile.doubleCells[:])

    return cells.reshape(tile.rows, tile.cols)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号