ঘোষণা :
15 এপ্রিল, 2025 এর আগে আর্থ ইঞ্জিন ব্যবহার করার জন্য নিবন্ধিত সমস্ত অবাণিজ্যিক প্রকল্পগুলিকে অবশ্যই আর্থ ইঞ্জিন অ্যাক্সেস বজায় রাখার জন্য
অ-বাণিজ্যিক যোগ্যতা যাচাই করতে হবে।
একটি ইমেজ সংগ্রহের উপর পুনরাবৃত্তি
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
যদিও map()
একটি সংগ্রহের প্রতিটি ছবিতে একটি ফাংশন প্রয়োগ করে, ফাংশনটি সংগ্রহের প্রতিটি চিত্র স্বাধীনভাবে পরিদর্শন করে। উদাহরণ স্বরূপ, ধরুন আপনি একটি টাইম সিরিজ থেকে টাইম t এ একটি ক্রমবর্ধমান অসঙ্গতি ( A t ) গণনা করতে চান। A t = f( চিত্র t , A t-1 ) ফর্মের একটি পুনরাবৃত্তিমূলকভাবে সংজ্ঞায়িত সিরিজ পেতে, ম্যাপিং কাজ করবে না কারণ ফাংশন ( f ) পূর্ববর্তী ফলাফলের ( A t-1 ) উপর নির্ভর করে। উদাহরণস্বরূপ, ধরুন আপনি একটি বেসলাইনের সাথে সম্পর্কিত ক্রমবর্ধমান নর্মালাইজড ডিফারেন্স ভেজিটেশন ইনডেক্স (NDVI) অসঙ্গতি চিত্রগুলির একটি সিরিজ গণনা করতে চান। ধরুন A 0 = 0 এবং f(চিত্র t , A t-1 ) = চিত্র t + A t-1 যেখানে A t-1 হল t-1 সময় পর্যন্ত ক্রমবর্ধমান বিসংগতি এবং t সময়ে চিত্র t হল অসামঞ্জস্য। এই পুনরাবৃত্তভাবে সংজ্ঞায়িত ImageCollection
তৈরি করতে imageCollection.iterate()
ব্যবহার করুন। নিম্নলিখিত উদাহরণে, ফাংশন accumulate()
দুটি পরামিতি নেয়: সংগ্রহে একটি চিত্র, এবং সমস্ত পূর্ববর্তী আউটপুটগুলির একটি তালিকা। iterate()
এর প্রতিটি কলের সাথে, চলমান যোগফলের সাথে অসামঞ্জস্যতা যোগ করা হয় এবং ফলাফল তালিকায় যোগ করা হয়। ইমেজগুলির একটি নতুন ক্রম পেতে চূড়ান্ত ফলাফলটি ImageCollection
কনস্ট্রাক্টরের কাছে পাঠানো হয়:
কোড এডিটর (জাভাস্ক্রিপ্ট)
// Load MODIS EVI imagery.
var collection = ee.ImageCollection('MODIS/006/MYD13A1').select('EVI');
// Define reference conditions from the first 10 years of data.
var reference = collection.filterDate('2001-01-01', '2010-12-31')
// Sort chronologically in descending order.
.sort('system:time_start', false);
// Compute the mean of the first 10 years.
var mean = reference.mean();
// Compute anomalies by subtracting the 2001-2010 mean from each image in a
// collection of 2011-2014 images. Copy the date metadata over to the
// computed anomaly images in the new collection.
var series = collection.filterDate('2011-01-01', '2014-12-31').map(function(image) {
return image.subtract(mean).set('system:time_start', image.get('system:time_start'));
});
// Display cumulative anomalies.
Map.setCenter(-100.811, 40.2, 5);
Map.addLayer(series.sum(),
{min: -60000, max: 60000, palette: ['FF0000', '000000', '00FF00']}, 'EVI anomaly');
// Get the timestamp from the most recent image in the reference collection.
var time0 = reference.first().get('system:time_start');
// Use imageCollection.iterate() to make a collection of cumulative anomaly over time.
// The initial value for iterate() is a list of anomaly images already processed.
// The first anomaly image in the list is just 0, with the time0 timestamp.
var first = ee.List([
// Rename the first band 'EVI'.
ee.Image(0).set('system:time_start', time0).select([0], ['EVI'])
]);
// This is a function to pass to Iterate().
// As anomaly images are computed, add them to the list.
var accumulate = function(image, list) {
// Get the latest cumulative anomaly image from the end of the list with
// get(-1). Since the type of the list argument to the function is unknown,
// it needs to be cast to a List. Since the return type of get() is unknown,
// cast it to Image.
var previous = ee.Image(ee.List(list).get(-1));
// Add the current anomaly to make a new cumulative anomaly image.
var added = image.add(previous)
// Propagate metadata to the new image.
.set('system:time_start', image.get('system:time_start'));
// Return the list with the cumulative anomaly inserted.
return ee.List(list).add(added);
};
// Create an ImageCollection of cumulative anomaly images by iterating.
// Since the return type of iterate is unknown, it needs to be cast to a List.
var cumulative = ee.ImageCollection(ee.List(series.iterate(accumulate, first)));
// Predefine the chart titles.
var title = {
title: 'Cumulative EVI anomaly over time',
hAxis: {title: 'Time'},
vAxis: {title: 'Cumulative EVI anomaly'},
};
// Chart some interesting locations.
var pt1 = ee.Geometry.Point(-65.544, -4.894);
print('Amazon rainforest:',
ui.Chart.image.series(
cumulative, pt1, ee.Reducer.first(), 500).setOptions(title));
var pt2 = ee.Geometry.Point(116.4647, 40.1054);
print('Beijing urbanization:',
ui.Chart.image.series(
cumulative, pt2, ee.Reducer.first(), 500).setOptions(title));
var pt3 = ee.Geometry.Point(-110.3412, 34.1982);
print('Arizona forest disturbance and recovery:',
ui.Chart.image.series(
cumulative, pt3, ee.Reducer.first(), 500).setOptions(title));
পাইথন সেটআপ
পাইথন এপিআই এবং ইন্টারেক্টিভ ডেভেলপমেন্টের জন্য geemap
ব্যবহার করার জন্য পাইথন এনভায়রনমেন্ট পৃষ্ঠাটি দেখুন।
import ee
import geemap.core as geemap
Colab (পাইথন)
import altair as alt
# Load MODIS EVI imagery.
collection = ee.ImageCollection('MODIS/006/MYD13A1').select('EVI')
# Define reference conditions from the first 10 years of data.
reference = collection.filterDate('2001-01-01', '2010-12-31').sort(
# Sort chronologically in descending order.
'system:time_start',
False,
)
# Compute the mean of the first 10 years.
mean = reference.mean()
# Compute anomalies by subtracting the 2001-2010 mean from each image in a
# collection of 2011-2014 images. Copy the date metadata over to the
# computed anomaly images in the new collection.
series = collection.filterDate('2011-01-01', '2014-12-31').map(
lambda image: image.subtract(mean).set(
'system:time_start', image.get('system:time_start')
)
)
# Display cumulative anomalies.
m = geemap.Map()
m.set_center(-100.811, 40.2, 5)
m.add_layer(
series.sum(),
{'min': -60000, 'max': 60000, 'palette': ['FF0000', '000000', '00FF00']},
'EVI anomaly',
)
display(m)
# Get the timestamp from the most recent image in the reference collection.
time_0 = reference.first().get('system:time_start')
# Use imageCollection.iterate() to make a collection of cumulative anomaly over time.
# The initial value for iterate() is a list of anomaly images already processed.
# The first anomaly image in the list is just 0, with the time_0 timestamp.
first = ee.List([
# Rename the first band 'EVI'.
ee.Image(0)
.set('system:time_start', time_0)
.select([0], ['EVI'])
])
# This is a function to pass to Iterate().
# As anomaly images are computed, add them to the list.
def accumulate(image, list):
# Get the latest cumulative anomaly image from the end of the list with
# get(-1). Since the type of the list argument to the function is unknown,
# it needs to be cast to a List. Since the return type of get() is unknown,
# cast it to Image.
previous = ee.Image(ee.List(list).get(-1))
# Add the current anomaly to make a new cumulative anomaly image.
added = image.add(previous).set(
# Propagate metadata to the new image.
'system:time_start',
image.get('system:time_start'),
)
# Return the list with the cumulative anomaly inserted.
return ee.List(list).add(added)
# Create an ImageCollection of cumulative anomaly images by iterating.
# Since the return type of iterate is unknown, it needs to be cast to a List.
cumulative = ee.ImageCollection(ee.List(series.iterate(accumulate, first)))
# Predefine the chart titles.
title = 'Cumulative EVI anomaly over time'
# Chart some interesting locations.
def display_chart(region, collection):
reduced = (
collection.filterBounds(region)
.sort('system:time_start')
.map(
lambda image: ee.Feature(
None,
image.reduceRegion(ee.Reducer.first(), region, 500).set(
'time', image.get('system:time_start')
),
)
)
)
reduced_dataframe = ee.data.computeFeatures(
{'expression': reduced, 'fileFormat': 'PANDAS_DATAFRAME'}
)
alt.Chart(reduced_dataframe).mark_line().encode(
alt.X('time:T').title('Time'),
alt.Y('EVI:Q').title('Cumulative EVI anomaly'),
).properties(title=title).display()
pt_1 = ee.Geometry.Point(-65.544, -4.894)
display('Amazon rainforest:')
display_chart(pt_1, cumulative)
pt_2 = ee.Geometry.Point(116.4647, 40.1054)
display('Beijing urbanization:')
display_chart(pt_2, cumulative)
pt_3 = ee.Geometry.Point(-110.3412, 34.1982)
display('Arizona forest disturbance and recovery:')
display_chart(pt_3, cumulative)
এই সিকোয়েন্সগুলি চার্ট করা ইঙ্গিত করে যে NDVI আগের ব্যাঘাতের তুলনায় স্থিতিশীল হচ্ছে কিনা বা NDVI একটি নতুন রাজ্যে প্রবণতা করছে কিনা। চার্ট বিভাগ থেকে আর্থ ইঞ্জিনে চার্ট সম্পর্কে আরও জানুন।
পুনরাবৃত্ত ফাংশন এটি সঞ্চালন করতে পারে অপারেশন সীমিত. বিশেষ করে, এটি ফাংশনের বাইরে ভেরিয়েবল পরিবর্তন করতে পারে না; এটা কিছু মুদ্রণ করতে পারে না; এটি জাভাস্ক্রিপ্ট 'if' বা 'for' বিবৃতি ব্যবহার করতে পারে না। যে কোনো ফলাফল আপনি সংগ্রহ করতে চান বা মধ্যবর্তী তথ্য যা আপনি পরবর্তী পুনরাবৃত্তিতে নিয়ে যেতে চান তা অবশ্যই ফাংশনের রিটার্ন মান হতে হবে। শর্তসাপেক্ষ অপারেশন করতে আপনি `ee.Algorithms.If()` ব্যবহার করতে পারেন।
অন্য কিছু উল্লেখ না করা থাকলে, এই পৃষ্ঠার কন্টেন্ট Creative Commons Attribution 4.0 License-এর অধীনে এবং কোডের নমুনাগুলি Apache 2.0 License-এর অধীনে লাইসেন্স প্রাপ্ত। আরও জানতে, Google Developers সাইট নীতি দেখুন। Java হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-07-24 UTC-তে শেষবার আপডেট করা হয়েছে।
[null,null,["2025-07-24 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003e\u003ccode\u003eimageCollection.iterate()\u003c/code\u003e is used to perform calculations that depend on previous results within an ImageCollection, unlike \u003ccode\u003emap()\u003c/code\u003e which processes each image independently.\u003c/p\u003e\n"],["\u003cp\u003eThis example demonstrates using \u003ccode\u003eiterate()\u003c/code\u003e to calculate cumulative anomalies of the Normalized Difference Vegetation Index (NDVI) over time.\u003c/p\u003e\n"],["\u003cp\u003eThe function passed to \u003ccode\u003eiterate()\u003c/code\u003e accumulates anomalies, adding the current image's anomaly to the running sum from previous iterations.\u003c/p\u003e\n"],["\u003cp\u003eResulting cumulative anomaly ImageCollection can be charted to analyze NDVI trends and disturbances over time in different locations.\u003c/p\u003e\n"],["\u003cp\u003eThe iterated function has limitations: it can't modify external variables, print, or use JavaScript 'if'/'for' statements, requiring results and intermediate information to be within its return value.\u003c/p\u003e\n"]]],["`imageCollection.iterate()` computes cumulative anomalies, unlike `map()`, which processes images independently. It defines a series *A~t~* = *f(Image~t~, A~t-1~)*, using a function to add the current anomaly to the previous cumulative anomaly. An example shows calculating cumulative Normalized Difference Vegetation Index (NDVI) anomalies, where `accumulate()` adds the current anomaly to a running sum. The result is stored in a list and then converted to a new `ImageCollection`. The function used in iterate cannot modify variables outside itself or use `if` or `for` statements.\n"],null,["# Iterating over an ImageCollection\n\nAlthough `map()` applies a function to every image in a collection, the\nfunction visits every image in the collection independently. For example, suppose you\nwant to compute a cumulative anomaly (*A~t~* ) at time *t* from a time\nseries. To obtain a recursively defined series of the form *A~t~ =\nf(Image~t~, A~t-1~)* , mapping won't work because the function\n(*f* ) depends on the previous result (*A~t-1~* ). For example, suppose\nyou want to compute a series of cumulative Normalized Difference Vegetation Index (NDVI)\nanomaly images relative to a baseline. Let *A~0~* = 0 and\n*f(Image~t~, A~t-1~)* = *Image~t~ + A~t-1~*\nwhere *A~t-1~* is the cumulative anomaly up to time *t-1* and\n*Image~t~* is the anomaly at time *t* . Use\n`imageCollection.iterate()` to make this recursively defined\n`ImageCollection`. In the following example, the function\n`accumulate()` takes two parameters: an image in the collection, and a list\nof all the previous outputs. With each call to `iterate()`, the anomaly is\nadded to the running sum and the result is added to the list. The final result is\npassed to the `ImageCollection` constructor to get a new sequence of images:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Load MODIS EVI imagery.\nvar collection = ee.ImageCollection('MODIS/006/MYD13A1').select('EVI');\n\n// Define reference conditions from the first 10 years of data.\nvar reference = collection.filterDate('2001-01-01', '2010-12-31')\n // Sort chronologically in descending order.\n .sort('system:time_start', false);\n\n// Compute the mean of the first 10 years.\nvar mean = reference.mean();\n\n// Compute anomalies by subtracting the 2001-2010 mean from each image in a\n// collection of 2011-2014 images. Copy the date metadata over to the\n// computed anomaly images in the new collection.\nvar series = collection.filterDate('2011-01-01', '2014-12-31').map(function(image) {\n return image.subtract(mean).set('system:time_start', image.get('system:time_start'));\n});\n\n// Display cumulative anomalies.\nMap.setCenter(-100.811, 40.2, 5);\nMap.addLayer(series.sum(),\n {min: -60000, max: 60000, palette: ['FF0000', '000000', '00FF00']}, 'EVI anomaly');\n\n// Get the timestamp from the most recent image in the reference collection.\nvar time0 = reference.first().get('system:time_start');\n\n// Use imageCollection.iterate() to make a collection of cumulative anomaly over time.\n// The initial value for iterate() is a list of anomaly images already processed.\n// The first anomaly image in the list is just 0, with the time0 timestamp.\nvar first = ee.List([\n // Rename the first band 'EVI'.\n ee.Image(0).set('system:time_start', time0).select([0], ['EVI'])\n]);\n\n// This is a function to pass to Iterate().\n// As anomaly images are computed, add them to the list.\nvar accumulate = function(image, list) {\n // Get the latest cumulative anomaly image from the end of the list with\n // get(-1). Since the type of the list argument to the function is unknown,\n // it needs to be cast to a List. Since the return type of get() is unknown,\n // cast it to Image.\n var previous = ee.Image(ee.List(list).get(-1));\n // Add the current anomaly to make a new cumulative anomaly image.\n var added = image.add(previous)\n // Propagate metadata to the new image.\n .set('system:time_start', image.get('system:time_start'));\n // Return the list with the cumulative anomaly inserted.\n return ee.List(list).add(added);\n};\n\n// Create an ImageCollection of cumulative anomaly images by iterating.\n// Since the return type of iterate is unknown, it needs to be cast to a List.\nvar cumulative = ee.ImageCollection(ee.List(series.iterate(accumulate, first)));\n\n// Predefine the chart titles.\nvar title = {\n title: 'Cumulative EVI anomaly over time',\n hAxis: {title: 'Time'},\n vAxis: {title: 'Cumulative EVI anomaly'},\n};\n\n// Chart some interesting locations.\nvar pt1 = ee.Geometry.Point(-65.544, -4.894);\nprint('Amazon rainforest:',\n ui.Chart.image.series(\n cumulative, pt1, ee.Reducer.first(), 500).setOptions(title));\n\nvar pt2 = ee.Geometry.Point(116.4647, 40.1054);\nprint('Beijing urbanization:',\n ui.Chart.image.series(\n cumulative, pt2, ee.Reducer.first(), 500).setOptions(title));\n\nvar pt3 = ee.Geometry.Point(-110.3412, 34.1982);\nprint('Arizona forest disturbance and recovery:',\n ui.Chart.image.series(\n cumulative, pt3, ee.Reducer.first(), 500).setOptions(title));\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\nimport altair as alt\n# Load MODIS EVI imagery.\ncollection = ee.ImageCollection('MODIS/006/MYD13A1').select('EVI')\n\n# Define reference conditions from the first 10 years of data.\nreference = collection.filterDate('2001-01-01', '2010-12-31').sort(\n # Sort chronologically in descending order.\n 'system:time_start',\n False,\n)\n\n# Compute the mean of the first 10 years.\nmean = reference.mean()\n\n# Compute anomalies by subtracting the 2001-2010 mean from each image in a\n# collection of 2011-2014 images. Copy the date metadata over to the\n# computed anomaly images in the new collection.\nseries = collection.filterDate('2011-01-01', '2014-12-31').map(\n lambda image: image.subtract(mean).set(\n 'system:time_start', image.get('system:time_start')\n )\n)\n\n# Display cumulative anomalies.\nm = geemap.Map()\nm.set_center(-100.811, 40.2, 5)\nm.add_layer(\n series.sum(),\n {'min': -60000, 'max': 60000, 'palette': ['FF0000', '000000', '00FF00']},\n 'EVI anomaly',\n)\ndisplay(m)\n\n# Get the timestamp from the most recent image in the reference collection.\ntime_0 = reference.first().get('system:time_start')\n\n# Use imageCollection.iterate() to make a collection of cumulative anomaly over time.\n# The initial value for iterate() is a list of anomaly images already processed.\n# The first anomaly image in the list is just 0, with the time_0 timestamp.\nfirst = ee.List([\n # Rename the first band 'EVI'.\n ee.Image(0)\n .set('system:time_start', time_0)\n .select([0], ['EVI'])\n])\n\n# This is a function to pass to Iterate().\n# As anomaly images are computed, add them to the list.\ndef accumulate(image, list):\n # Get the latest cumulative anomaly image from the end of the list with\n # get(-1). Since the type of the list argument to the function is unknown,\n # it needs to be cast to a List. Since the return type of get() is unknown,\n # cast it to Image.\n previous = ee.Image(ee.List(list).get(-1))\n # Add the current anomaly to make a new cumulative anomaly image.\n added = image.add(previous).set(\n # Propagate metadata to the new image.\n 'system:time_start',\n image.get('system:time_start'),\n )\n # Return the list with the cumulative anomaly inserted.\n return ee.List(list).add(added)\n\n# Create an ImageCollection of cumulative anomaly images by iterating.\n# Since the return type of iterate is unknown, it needs to be cast to a List.\ncumulative = ee.ImageCollection(ee.List(series.iterate(accumulate, first)))\n\n# Predefine the chart titles.\ntitle = 'Cumulative EVI anomaly over time'\n\n# Chart some interesting locations.\ndef display_chart(region, collection):\n reduced = (\n collection.filterBounds(region)\n .sort('system:time_start')\n .map(\n lambda image: ee.Feature(\n None,\n image.reduceRegion(ee.Reducer.first(), region, 500).set(\n 'time', image.get('system:time_start')\n ),\n )\n )\n )\n reduced_dataframe = ee.data.computeFeatures(\n {'expression': reduced, 'fileFormat': 'PANDAS_DATAFRAME'}\n )\n alt.Chart(reduced_dataframe).mark_line().encode(\n alt.X('time:T').title('Time'),\n alt.Y('EVI:Q').title('Cumulative EVI anomaly'),\n ).properties(title=title).display()\n\npt_1 = ee.Geometry.Point(-65.544, -4.894)\ndisplay('Amazon rainforest:')\ndisplay_chart(pt_1, cumulative)\n\npt_2 = ee.Geometry.Point(116.4647, 40.1054)\ndisplay('Beijing urbanization:')\ndisplay_chart(pt_2, cumulative)\n\npt_3 = ee.Geometry.Point(-110.3412, 34.1982)\ndisplay('Arizona forest disturbance and recovery:')\ndisplay_chart(pt_3, cumulative)\n```\n\nCharting these sequences indicates whether NDVI is stabilizing relative to previous\ndisturbances or whether NDVI is trending to a new state. Learn more about charts in\nEarth Engine from the [Charts section](/earth-engine/guides/charts).\n\nThe iterated function is limited in the operations it can perform. Specifically, it can't\nmodify variables outside the function; it can't print anything; it can't use JavaScript 'if'\nor 'for' statements. Any results you wish to collect or intermediate information you wish to\ncarry over to the next iteration must be in the function's return value. You can use\n\\`ee.Algorithms.If()\\` to perform conditional operations."]]