お知らせ:
2025 年 4 月 15 日より前に Earth Engine の使用を登録したすべての非商用プロジェクトは、アクセスを維持するために
非商用目的での利用資格を確認する必要があります。2025 年 9 月 26 日までに確認が完了していない場合、アクセスが保留されることがあります。
ee.Number.clamp
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
値を最小値から最大値の範囲内に収めます。
| 用途 | 戻り値 |
|---|
Number.clamp(min, max) | 数値 |
| 引数 | タイプ | 詳細 |
|---|
これ: number | 数値 | |
min | 浮動小数点数 | クランプする最小値。 |
max | 浮動小数点数 | クランプする最大値。 |
例
コードエディタ(JavaScript)
// Numbers within range are unaffected.
print('100 clamped to range [0,255]', ee.Number(100).clamp(0, 255)); // 100
// Numbers greater than max in range are set to max.
print('259 clamped to range [0,255]', ee.Number(259).clamp(0, 255)); // 255
// Numbers less than min in range are set to min.
print('-259 clamped to range [0,255]', ee.Number(-259).clamp(0, 255)); // 0
Python の設定
Python API とインタラクティブな開発での geemap の使用については、
Python 環境のページをご覧ください。
import ee
import geemap.core as geemap
Colab(Python)
# Numbers within range are unaffected.
# 100
display('100 clamped to range [0,255]:', ee.Number(100).clamp(0, 255))
# Numbers greater than max in range are set to max.
# 255
display('259 clamped to range [0,255]:', ee.Number(259).clamp(0, 255))
# Numbers less than min in range are set to min.
# 0
display('-259 clamped to range [0,255]:', ee.Number(-259).clamp(0, 255))
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-10-30 UTC。
[null,null,["最終更新日 2025-10-30 UTC。"],[],["The `clamp(min, max)` function restricts a number within a specified range. It accepts a number, a minimum (`min`), and a maximum (`max`) value as arguments. If the number falls within the `min` and `max` range, it remains unchanged. Numbers exceeding `max` are set to `max`, and those below `min` are set to `min`. The function returns a number. Example, `100` within the range of `0,255` will stay as `100`, while `259` becomes `255` and `-259` becomes `0` in the same range.\n"]]