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)
评论列表
文章目录