הודעה : כל הפרויקטים הלא מסחריים שנרשמו לשימוש ב-Earth Engine לפני
15 באפריל 2025 חייבים
לאמת את הזכאות לשימוש לא מסחרי כדי לשמור על הגישה. אם לא תאמתו את החשבון עד 26 בספטמבר 2025, יכול להיות שהגישה שלכם תושעה.
שליחת משוב
ee.List.iterate
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
איטרציה של אלגוריתם על רשימה. האלגוריתם אמור לקבל שני אובייקטים, את הפריט הנוכחי ברשימה ואת התוצאה מהאיטרציה הקודמת או את הערך של first באיטרציה הראשונה.
שימוש החזרות List. iterate (function, first)
אובייקט
ארגומנט סוג פרטים זה: list
רשימה function
אלגוריתם first
אובייקט
דוגמאות
עורך הקוד (JavaScript)
// This example uses the ee.List.iterate function to generate a series of
// sequentially halved values.
// Declare a list that will hold the series of sequentially halved values,
// initialize it with the starting quantity.
var quantityList = [ 1000 ];
// Define the number of iterations as a list sequence.
var nSteps = ee . List . sequence ( 1 , 10 );
// Declare a function that takes the current element of the iteration list and
// the returned result of the previous iteration as inputs. In this case, the
// the function is returning an accumulating list of quantities that are reduced
// by half at each iteration.
var halfOfPrevious = function ( currentElement , previousResult ) {
var previousQuantity = ee . Number ( ee . List ( previousResult ). get ( - 1 ));
var currentQuantity = previousQuantity . divide ( 2 );
return ee . List ( previousResult ). add ( currentQuantity );
};
// Apply the function to the nSteps list, each element is an iteration.
quantityList = ee . List ( nSteps . iterate ( halfOfPrevious , quantityList ));
// Display the results. Note that step 0 is included for the initial value.
print ( 'Steps in the iteration of halved quantities' , nSteps );
print ( 'Series of sequentially halved quantities' , quantityList );
print ( ui . Chart . array . values ({
array : quantityList ,
axis : 0 ,
xLabels : ee . List ([ 0 ]). cat ( nSteps )
}));
הגדרת Python
מידע על Python API ועל שימוש ב-geemap
לפיתוח אינטראקטיבי מופיע בדף
Python Environment .
import ee
import geemap.core as geemap
Colab (Python)
import matplotlib.pyplot as plt
# This example uses the ee.List.iterate function to generate a series of
# sequentially halved values.
# Declare a list that will hold the series of sequentially halved values,
# initialize it with the starting quantity.
quantity_list = [ 1000 ]
# Define the number of iterations as a list sequence.
n_steps = ee . List . sequence ( 1 , 10 )
# Declare a function that takes the current element of the iteration list and
# the returned result of the previous iteration as inputs. In this case, the
# the function is returning an accumulating list of quantities that are reduced
# by half at each iteration.
def half_of_previous ( current_element , previous_result ):
previous_quantity = ee . Number ( ee . List ( previous_result ) . get ( - 1 ))
current_quantity = previous_quantity . divide ( 2 )
return ee . List ( previous_result ) . add ( current_quantity )
# Apply the function to the n_steps list, each element is an iteration.
quantity_list = ee . List ( n_steps . iterate ( half_of_previous , quantity_list ))
# Display the results.
display ( 'Steps in the iteration of halved quantities' , n_steps )
display ( 'Series of sequentially halved quantities' , quantity_list )
quantity_list_client = quantity_list . getInfo ()
plt . scatter ( range ( len ( quantity_list_client )), quantity_list_client )
plt . show ()
שליחת משוב
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 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)."],[],[]]