お知らせ :
2025 年 4 月 15 日 より前に Earth Engine の使用を登録したすべての非商用プロジェクトは、アクセスを維持するために
非商用目的での利用資格を確認 する必要があります。2025 年 9 月 26 日までに確認が完了していない場合、アクセスが保留されることがあります。
フィードバックを送信
ee.Number.byte
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
入力値を符号なし 8 ビット整数にキャストします。
例
コードエディタ(JavaScript)
// Cast a number to unsigned 8-bit integer: [0, 255].
var number = ee . Number ( 100 );
print ( 'Number:' , number );
var byteNumber = number . byte ();
print ( 'Number cast to byte:' , byteNumber );
/**
* Casting numbers to byte that are outside of its range and precision can
* modify the resulting value, note the behavior of the following scenarios.
*/
// A floating point number cast to byte loses decimal precision.
var float = ee . Number ( 1.7 );
print ( 'Floating point value:' , float );
var floatToByte = float . byte ();
print ( 'Floating point value cast to byte:' , floatToByte );
// A number greater than byte range max cast to byte becomes byte range max.
var BYTE_MAX = 255 ;
var outOfRangeHi = ee . Number ( BYTE_MAX + 12345 );
print ( 'Greater than byte max:' , outOfRangeHi );
var outOfRangeHiToByte = outOfRangeHi . byte ();
print ( 'Greater than byte max cast to byte becomes byte max:' , outOfRangeHiToByte );
// A number greater than byte range min cast to byte becomes byte range min.
var BYTE_MIN = 0 ;
var outOfRangeLo = ee . Number ( BYTE_MIN - 12345 );
print ( 'Less than byte min:' , outOfRangeLo );
var outOfRangeLoToByte = outOfRangeLo . byte ();
print ( 'Less than byte min cast to byte becomes byte min:' , outOfRangeLoToByte );
Python の設定
Python API とインタラクティブな開発での geemap
の使用については、
Python 環境 のページをご覧ください。
import ee
import geemap.core as geemap
Colab(Python)
# Cast a number to unsigned 8-bit integer: [0, 255].
number = ee . Number ( 100 )
print ( 'Number:' , number . getInfo ())
byte_number = number . byte ()
print ( 'Number cast to byte:' , byte_number . getInfo ())
"""Casting numbers to byte that are outside of its range and precision can
modify the resulting value, note the behavior of the following scenarios.
"""
# A floating point number cast to byte loses decimal precision.
float_number = ee . Number ( 1.7 )
print ( 'Floating point value:' , float_number . getInfo ())
float_to_byte = float_number . byte ()
print ( 'Floating point value cast to byte:' , float_to_byte . getInfo ())
# A number greater than byte range max cast to byte becomes byte range max.
BYTE_MAX = 255
out_of_range_hi = ee . Number ( BYTE_MAX + 12345 )
print ( 'Greater than byte max:' , out_of_range_hi . getInfo ())
out_of_range_hi_to_byte = out_of_range_hi . byte ()
print ( 'Greater than byte max cast to byte becomes byte max:' ,
out_of_range_hi_to_byte . getInfo ())
# A number greater than byte range min cast to byte becomes byte range min.
BYTE_MIN = 0
out_of_range_lo = ee . Number ( BYTE_MIN - 12345 )
print ( 'Less than byte min:' , out_of_range_lo . getInfo ())
out_of_range_lo_to_byte = out_of_range_lo . byte ()
print ( 'Less than byte min cast to byte becomes byte min:' ,
out_of_range_lo_to_byte . getInfo ())
フィードバックを送信
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンス により使用許諾されます。コードサンプルは Apache 2.0 ライセンス により使用許諾されます。詳しくは、Google Developers サイトのポリシー をご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-26 UTC。
ご意見をお聞かせください
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-26 UTC。"],[],["The `byte()` method casts a number to an unsigned 8-bit integer, ranging from 0 to 255. Floating-point numbers lose decimal precision when cast. Numbers exceeding the byte range maximum (255) are capped at 255, and those below the minimum (0) become 0. The input value is cast to this range, modifying its value if outside of 0-255.\n"]]