ประกาศ : โปรเจ็กต์ที่ไม่ใช่เชิงพาณิชย์ทั้งหมดที่ลงทะเบียนเพื่อใช้ Earth Engine ก่อนวันที่
15 เมษายน 2025 ต้อง
ยืนยันการมีสิทธิ์ที่ไม่ใช่เชิงพาณิชย์ เพื่อรักษาสิทธิ์เข้าถึง หากคุณไม่ยืนยันภายในวันที่ 26 กันยายน 2025 ระบบอาจระงับสิทธิ์เข้าถึงของคุณ
ส่งความคิดเห็น
ee.Number.byte
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
แปลงค่าอินพุตเป็นจำนวนเต็มแบบไม่มีเครื่องหมาย 8 บิต
การใช้งาน การคืนสินค้า Number. byte ()
ตัวเลข
อาร์กิวเมนต์ ประเภท รายละเอียด ดังนี้ input
ตัวเลข ค่าอินพุต
ตัวอย่าง
โปรแกรมแก้ไขโค้ด (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"]]