ঘোষণা :
15 এপ্রিল, 2025 এর আগে আর্থ ইঞ্জিন ব্যবহার করার জন্য নিবন্ধিত সমস্ত অবাণিজ্যিক প্রকল্পগুলিকে অবশ্যই আর্থ ইঞ্জিন অ্যাক্সেস বজায় রাখার জন্য
অ-বাণিজ্যিক যোগ্যতা যাচাই করতে হবে।
ওয়েটেড রিডাকশন
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
ডিফল্টরূপে, মাস্ক মান অনুযায়ী ইমেজের ওজনে ইনপুটগুলি প্রয়োগ করা হয়। এটি clip()
মতো ক্রিয়াকলাপের মাধ্যমে তৈরি ভগ্নাংশ পিক্সেলের প্রসঙ্গে প্রাসঙ্গিক। রিডুসারে unweighted()
কল করে এই আচরণটি সামঞ্জস্য করুন। একটি ওজনহীন রিডুসার ব্যবহার করে অঞ্চলের সমস্ত পিক্সেলকে একই ওজন থাকতে বাধ্য করে৷ নিম্নলিখিত উদাহরণটি ব্যাখ্যা করে কিভাবে পিক্সেল ওজন হ্রাসকারী আউটপুটকে প্রভাবিত করতে পারে:
কোড এডিটর (জাভাস্ক্রিপ্ট)
// Load a Landsat 8 input image.
var image = ee.Image('LANDSAT/LC08/C02/T1/LC08_044034_20140318');
// Create an arbitrary region.
var geometry = ee.Geometry.Rectangle(-122.496, 37.532, -121.554, 37.538);
// Make an NDWI image. It will have one band named 'nd'.
var ndwi = image.normalizedDifference(['B3', 'B5']);
// Compute the weighted mean of the NDWI image clipped to the region.
var weighted = ndwi.clip(geometry)
.reduceRegion({
reducer: ee.Reducer.mean(),
geometry: geometry,
scale: 30})
.get('nd');
// Compute the UN-weighted mean of the NDWI image clipped to the region.
var unweighted = ndwi.clip(geometry)
.reduceRegion({
reducer: ee.Reducer.mean().unweighted(),
geometry: geometry,
scale: 30})
.get('nd');
// Observe the difference between weighted and unweighted reductions.
print('weighted:', weighted);
print('unweighted', unweighted);
পাইথন সেটআপ
পাইথন এপিআই এবং ইন্টারেক্টিভ ডেভেলপমেন্টের জন্য geemap
ব্যবহার করার জন্য পাইথন এনভায়রনমেন্ট পৃষ্ঠাটি দেখুন।
import ee
import geemap.core as geemap
Colab (পাইথন)
# Load a Landsat 8 input image.
image = ee.Image('LANDSAT/LC08/C02/T1/LC08_044034_20140318')
# Create an arbitrary region.
geometry = ee.Geometry.Rectangle(-122.496, 37.532, -121.554, 37.538)
# Make an NDWI image. It will have one band named 'nd'.
ndwi = image.normalizedDifference(['B3', 'B5'])
# Compute the weighted mean of the NDWI image clipped to the region.
weighted = (
ndwi.clip(geometry)
.reduceRegion(reducer=ee.Reducer.mean(), geometry=geometry, scale=30)
.get('nd')
)
# Compute the UN-weighted mean of the NDWI image clipped to the region.
unweighted = (
ndwi.clip(geometry)
.reduceRegion(
reducer=ee.Reducer.mean().unweighted(), geometry=geometry, scale=30
)
.get('nd')
)
# Observe the difference between weighted and unweighted reductions.
display('weighted:', weighted)
display('unweighted', unweighted)
রিডুসারে unweighted()
কল করার ফলে অঞ্চলের প্রান্তে থাকা পিক্সেলগুলির একটি ওজন প্রাপ্ত হওয়ার কারণে ফলাফলের পার্থক্য।
একটি স্পষ্টভাবে ওজনযুক্ত আউটপুট পাওয়ার জন্য, রিডুসারে বলা splitWeights()
দিয়ে স্পষ্টভাবে ওজন সেট করা বাঞ্ছনীয়। splitWeights()
দ্বারা পরিবর্তিত একটি রিডুসার দুটি ইনপুট নেয়, যেখানে দ্বিতীয় ইনপুটটি ওজন। নিম্নোক্ত উদাহরণটি ক্লাউড স্কোর splitWeights()
প্রদত্ত ওজনের সাথে (ক্লাউডিয়ার, ওজন কম):
কোড এডিটর (জাভাস্ক্রিপ্ট)
// Load an input Landsat 8 image.
var image = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_186059_20130419');
// Compute cloud score and reverse it such that the highest
// weight (100) is for the least cloudy pixels.
var cloudWeight = ee.Image(100).subtract(
ee.Algorithms.Landsat.simpleCloudScore(image).select(['cloud']));
// Compute NDVI and add the cloud weight band.
var ndvi = image.normalizedDifference(['B5', 'B4']).addBands(cloudWeight);
// Define an arbitrary region in a cloudy area.
var region = ee.Geometry.Rectangle(9.9069, 0.5981, 10.5, 0.9757);
// Use a mean reducer.
var reducer = ee.Reducer.mean();
// Compute the unweighted mean.
var unweighted = ndvi.select(['nd']).reduceRegion(reducer, region, 30);
// compute mean weighted by cloudiness.
var weighted = ndvi.reduceRegion(reducer.splitWeights(), region, 30);
// Observe the difference as a result of weighting by cloudiness.
print('unweighted:', unweighted);
print('weighted:', weighted);
পাইথন সেটআপ
পাইথন এপিআই এবং ইন্টারেক্টিভ ডেভেলপমেন্টের জন্য geemap
ব্যবহার করার জন্য পাইথন এনভায়রনমেন্ট পৃষ্ঠাটি দেখুন।
import ee
import geemap.core as geemap
Colab (পাইথন)
# Load an input Landsat 8 image.
image = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_186059_20130419')
# Compute cloud score and reverse it such that the highest
# weight (100) is for the least cloudy pixels.
cloud_weight = ee.Image(100).subtract(
ee.Algorithms.Landsat.simpleCloudScore(image).select(['cloud'])
)
# Compute NDVI and add the cloud weight band.
ndvi = image.normalizedDifference(['B5', 'B4']).addBands(cloud_weight)
# Define an arbitrary region in a cloudy area.
region = ee.Geometry.Rectangle(9.9069, 0.5981, 10.5, 0.9757)
# Use a mean reducer.
reducer = ee.Reducer.mean()
# Compute the unweighted mean.
unweighted = ndvi.select(['nd']).reduceRegion(reducer, region, 30)
# compute mean weighted by cloudiness.
weighted = ndvi.reduceRegion(reducer.splitWeights(), region, 30)
# Observe the difference as a result of weighting by cloudiness.
display('unweighted:', unweighted)
display('weighted:', weighted)
লক্ষ্য করুন যে cloudWeight
reduceRegion()
কল করার আগে একটি ব্যান্ড হিসাবে যুক্ত করা দরকার। ফলাফলটি নির্দেশ করে যে মেঘলা পিক্সেলের ওজন হ্রাসের ফলে আনুমানিক গড় এনডিভিআই বেশি।
অন্য কিছু উল্লেখ না করা থাকলে, এই পৃষ্ঠার কন্টেন্ট Creative Commons Attribution 4.0 License-এর অধীনে এবং কোডের নমুনাগুলি Apache 2.0 License-এর অধীনে লাইসেন্স প্রাপ্ত। আরও জানতে, Google Developers সাইট নীতি দেখুন। Java হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-07-25 UTC-তে শেষবার আপডেট করা হয়েছে।
[null,null,["2025-07-25 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003eBy default, reducers in Earth Engine weight pixels based on their mask values, which can affect results when using operations like \u003ccode\u003eclip()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eunweighted()\u003c/code\u003e function forces all pixels in a region to have equal weight when applying a reducer.\u003c/p\u003e\n"],["\u003cp\u003eTo explicitly control pixel weights, use \u003ccode\u003esplitWeights()\u003c/code\u003e on the reducer and provide a separate weight band in the input image.\u003c/p\u003e\n"],["\u003cp\u003eUsing weighted reducers allows for more accurate analysis by adjusting the influence of specific pixels based on factors like cloud cover.\u003c/p\u003e\n"]]],["Reducers, by default, weight image inputs based on mask values, relevant for fractional pixels. The `unweighted()` method forces equal pixel weighting within a region. `splitWeights()` allows for explicit weighting, demonstrated by weighting a mean Normalized Difference Vegetation Index (NDVI) by cloud score, reducing cloudy pixel influence. The difference between using weighted, unweighted or splitweight methods is illustrated with examples of Landsat 8 imagery using `reduceRegion()`. Weights should be added as bands before using `reduceRegion()`.\n"],null,["# Weighted Reductions\n\nBy default, reducers applied to imagery weight the inputs according to the mask value.\nThis is relevant in the context of fractional pixels created through operations such as\n`clip()`. Adjust this behavior by calling `unweighted()` on the\nreducer. Using an unweighted reducer forces all pixels in the region to have the same\nweight. The following example illustrates how pixel weighting can affect the reducer\noutput:\n\n### Code Editor (JavaScript)\n\n```javascript\n// Load a Landsat 8 input image.\nvar image = ee.Image('LANDSAT/LC08/C02/T1/LC08_044034_20140318');\n\n// Create an arbitrary region.\nvar geometry = ee.Geometry.Rectangle(-122.496, 37.532, -121.554, 37.538);\n\n// Make an NDWI image. It will have one band named 'nd'.\nvar ndwi = image.normalizedDifference(['B3', 'B5']);\n\n// Compute the weighted mean of the NDWI image clipped to the region.\nvar weighted = ndwi.clip(geometry)\n .reduceRegion({\n reducer: ee.Reducer.mean(),\n geometry: geometry,\n scale: 30})\n .get('nd');\n\n// Compute the UN-weighted mean of the NDWI image clipped to the region.\nvar unweighted = ndwi.clip(geometry)\n .reduceRegion({\n reducer: ee.Reducer.mean().unweighted(),\n geometry: geometry,\n scale: 30})\n .get('nd');\n\n// Observe the difference between weighted and unweighted reductions.\nprint('weighted:', weighted);\nprint('unweighted', unweighted);\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\n# Load a Landsat 8 input image.\nimage = ee.Image('LANDSAT/LC08/C02/T1/LC08_044034_20140318')\n\n# Create an arbitrary region.\ngeometry = ee.Geometry.Rectangle(-122.496, 37.532, -121.554, 37.538)\n\n# Make an NDWI image. It will have one band named 'nd'.\nndwi = image.normalizedDifference(['B3', 'B5'])\n\n# Compute the weighted mean of the NDWI image clipped to the region.\nweighted = (\n ndwi.clip(geometry)\n .reduceRegion(reducer=ee.Reducer.mean(), geometry=geometry, scale=30)\n .get('nd')\n)\n\n# Compute the UN-weighted mean of the NDWI image clipped to the region.\nunweighted = (\n ndwi.clip(geometry)\n .reduceRegion(\n reducer=ee.Reducer.mean().unweighted(), geometry=geometry, scale=30\n )\n .get('nd')\n)\n\n# Observe the difference between weighted and unweighted reductions.\ndisplay('weighted:', weighted)\ndisplay('unweighted', unweighted)\n```\n\nThe difference in results is due to pixels at the edge of the region receiving a weight\nof one as a result of calling `unweighted()` on the reducer.\n\nIn order to obtain an explicitly weighted output, it is preferable to set the weights\nexplicitly with `splitWeights()` called on the reducer. A reducer modified by\n`splitWeights()` takes two inputs, where the second input is the weight. The\nfollowing example illustrates `splitWeights()` by computing the weighted mean\nNormalized Difference Vegetation Index (NDVI) in a region, with the weights given by\ncloud score (the cloudier, the lower the weight):\n\n### Code Editor (JavaScript)\n\n```javascript\n// Load an input Landsat 8 image.\nvar image = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_186059_20130419');\n\n// Compute cloud score and reverse it such that the highest\n// weight (100) is for the least cloudy pixels.\nvar cloudWeight = ee.Image(100).subtract(\n ee.Algorithms.Landsat.simpleCloudScore(image).select(['cloud']));\n\n// Compute NDVI and add the cloud weight band.\nvar ndvi = image.normalizedDifference(['B5', 'B4']).addBands(cloudWeight);\n\n// Define an arbitrary region in a cloudy area.\nvar region = ee.Geometry.Rectangle(9.9069, 0.5981, 10.5, 0.9757);\n\n// Use a mean reducer.\nvar reducer = ee.Reducer.mean();\n\n// Compute the unweighted mean.\nvar unweighted = ndvi.select(['nd']).reduceRegion(reducer, region, 30);\n\n// compute mean weighted by cloudiness.\nvar weighted = ndvi.reduceRegion(reducer.splitWeights(), region, 30);\n\n// Observe the difference as a result of weighting by cloudiness.\nprint('unweighted:', unweighted);\nprint('weighted:', weighted);\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\n# Load an input Landsat 8 image.\nimage = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_186059_20130419')\n\n# Compute cloud score and reverse it such that the highest\n# weight (100) is for the least cloudy pixels.\ncloud_weight = ee.Image(100).subtract(\n ee.Algorithms.Landsat.simpleCloudScore(image).select(['cloud'])\n)\n\n# Compute NDVI and add the cloud weight band.\nndvi = image.normalizedDifference(['B5', 'B4']).addBands(cloud_weight)\n\n# Define an arbitrary region in a cloudy area.\nregion = ee.Geometry.Rectangle(9.9069, 0.5981, 10.5, 0.9757)\n\n# Use a mean reducer.\nreducer = ee.Reducer.mean()\n\n# Compute the unweighted mean.\nunweighted = ndvi.select(['nd']).reduceRegion(reducer, region, 30)\n\n# compute mean weighted by cloudiness.\nweighted = ndvi.reduceRegion(reducer.splitWeights(), region, 30)\n\n# Observe the difference as a result of weighting by cloudiness.\ndisplay('unweighted:', unweighted)\ndisplay('weighted:', weighted)\n```\n\nObserve that `cloudWeight` needs to be added as a band prior to calling\n`reduceRegion()`. The result indicates that the estimated mean NDVI is\nhigher as a result of decreasing the weight of cloudy pixels."]]