ee.Image.cast
Casts some or all bands of an image to the specified types.
Usage | Returns |
---|
Image.cast(bandTypes, bandOrder) | Image |
Argument | Type | Details |
---|
this: image | Image | The image to cast. |
bandTypes | Dictionary | A dictionary from band name to band types. Types can be PixelTypes or strings. The valid strings are: 'int8', 'int16', 'int32', 'int64', 'uint8', 'uint16', 'uint32', 'byte', 'short', 'int', 'long', 'float', and 'double'. If bandTypes includes bands that are not already in the input image, they will be added to the image as transparent bands. If bandOrder isn't also specified, new bands will be appended in alphabetical order. |
bandOrder | List, default: null | A list specifying the order of the bands in the result. If specified, must match the full list of bands in the result. |
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-13 UTC.
[null,null,["Last updated 2024-07-13 UTC."],[[["Casts image bands to specified data types like 'int8', 'float', etc., allowing for data type conversions within an image."],["Accepts a dictionary mapping band names to desired types, enabling selective casting for individual bands."],["Can introduce new bands with specified types, appending them to the image with optional ordering using the `bandOrder` parameter."],["Returns a new Image with the converted bands, preserving the original image unchanged."]]],["The `Image.cast` function modifies an image by changing the data type of its bands. It takes a dictionary, `bandTypes`, mapping band names to new data types (PixelTypes or strings like 'int8', 'float'). If a specified band is not present in the original image, a transparent band of that type is added. An optional `bandOrder` list defines the sequence of the resulting bands. The function returns the modified `Image`.\n"]]