همانطور که در سند طرحها ذکر شده است، Earth Engine بهطور پیشفرض درطول بازطرح، نمونهبرداری مجدد نزدیکترین همسایه را انجام میدهد. میتوانید این رفتار را
با روشهای resample() یا reduceResolution() تغییر دهید. بهطور مشخص، وقتی یکی از این روشها برای تصویر ورودی اعمال میشود، هرگونه بازافکنی لازم برای ورودی بااستفاده از روش نمونهگیری مجدد یا انبوهش نشاندادهشده انجام خواهد شد.
نمونهبرداری مجدد
resample() باعث میشود روش نمونهگیری مجدد نشاندادهشده ('bilinear' یا
'bicubic') در بازنمایی بعدی استفاده شود. ازآنجاییکه ورودیها در تصویر خروجی درخواست میشوند، ممکن است قبلاز هر عملیات دیگری روی ورودی، یک تصویرسازی مجدد ضمنی اتفاق بیفتد. به همین دلیل، resample() را مستقیماً روی تصویر ورودی
فراخوانی کنید. مثال ساده زیر را درنظر بگیرید:
ویرایشگر کد (جاوا اسکریپت)
// Load a Landsat image over San Francisco, California, UAS. var landsat = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20160323'); // Set display and visualization parameters. Map.setCenter(-122.37383, 37.6193, 15); var visParams = {bands: ['B4', 'B3', 'B2'], max: 0.3}; // Display the Landsat image using the default nearest neighbor resampling. // when reprojecting to Mercator for the Code Editor map. Map.addLayer(landsat, visParams, 'original image'); // Force the next reprojection on this image to use bicubic resampling. var resampled = landsat.resample('bicubic'); // Display the Landsat image using bicubic resampling. Map.addLayer(resampled, visParams, 'resampled');
import ee import geemap.core as geemap
Colab (Python)
# Load a Landsat image over San Francisco, California, UAS. landsat = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20160323') # Set display and visualization parameters. m = geemap.Map() m.set_center(-122.37383, 37.6193, 15) vis_params = {'bands': ['B4', 'B3', 'B2'], 'max': 0.3} # Display the Landsat image using the default nearest neighbor resampling. # when reprojecting to Mercator for the Code Editor map. m.add_layer(landsat, vis_params, 'original image') # Force the next reprojection on this image to use bicubic resampling. resampled = landsat.resample('bicubic') # Display the Landsat image using bicubic resampling. m.add_layer(resampled, vis_params, 'resampled')
توجه داشته باشید که نمونهبرداری مجدد 'bicubic' باعث میشود پیکسلهای خروجی در مقایسه با تصویر اصلی هموارتر بهنظر برسند (شکل ۱).
ترتیب عملیات برای این نمونه کد در شکل ۲ نشان داده شده است. بهطور خاص، بازافکنی ضمنی به افکنش نقشههای مرکاتور با روش نمونهبرداری مجدد مشخصشده در تصویر ورودی انجام میشود.

شکل ۲. نمودار جریان عملیات وقتی resample() در تصویر ورودی قبلاز نمایش در «ویرایشگر کد» فراخوانی میشود. خطوط منحنی جریان اطلاعات به بازپخش را نشان میدهند: بهطور خاص، پخش خروجی، مقیاس، و روش نمونهگیری مجدد برای استفاده.
کاهش وضوح
فرض کنید بهجای نمونهبرداری مجدد درطول بازطرحریزی، هدف شما این است که
پیکسلها را در طرحریزی متفاوتی به پیکسلهای بزرگتر جمعآوری کنید. این کار هنگام مقایسه مجموعه دادههای تصویر در مقیاسهای مختلف مفید است، برای مثال پیکسلهای ۳۰ متری از محصول مبتنی بر Landsat با پیکسلهای درشت (مقیاس بالاتر) از محصول مبتنی بر MODIS. میتوانید این فرایند تجمیع را با روش reduceResolution() کنترل کنید. همانند resample()، reduceResolution() را در ورودی فراخوانی کنید تا بر بازفرافکنی بعدی تصویر تأثیر بگذارد. مثال زیر از
reduceResolution() برای مقایسه دادههای پوشش جنگلی با وضوح ۳۰ متر با
شاخص پوشش گیاهی با وضوح ۵۰۰ متر استفاده میکند:
ویرایشگر کد (جاوا اسکریپت)
// Load a MODIS EVI image. var modis = ee.Image(ee.ImageCollection('MODIS/061/MOD13A1').first()) .select('EVI'); // Display the EVI image near La Honda, California. Map.setCenter(-122.3616, 37.5331, 12); Map.addLayer(modis, {min: 2000, max: 5000}, 'MODIS EVI'); // Get information about the MODIS projection. var modisProjection = modis.projection(); print('MODIS projection:', modisProjection); // Load and display forest cover data at 30 meters resolution. var forest = ee.Image('UMD/hansen/global_forest_change_2025_v1_13') .select('treecover2000'); Map.addLayer(forest, {max: 80}, 'forest cover 30 m'); // Get the forest cover data at MODIS scale and projection. var forestMean = forest // Force the next reprojection to aggregate instead of resampling. .reduceResolution({ reducer: ee.Reducer.mean(), maxPixels: 1024 }) // Request the data at the scale and projection of the MODIS image. .reproject({ crs: modisProjection }); // Display the aggregated, reprojected forest cover data. Map.addLayer(forestMean, {max: 80}, 'forest cover at MODIS scale');
import ee import geemap.core as geemap
Colab (Python)
# Load a MODIS EVI image. modis = ee.Image(ee.ImageCollection('MODIS/061/MOD13A1').first()).select('EVI') # Display the EVI image near La Honda, California. m.set_center(-122.3616, 37.5331, 12) m.add_layer(modis, {'min': 2000, 'max': 5000}, 'MODIS EVI') # Get information about the MODIS projection. modis_projection = modis.projection() display('MODIS projection:', modis_projection) # Load and display forest cover data at 30 meters resolution. forest = ee.Image('UMD/hansen/global_forest_change_2025_v1_13').select( 'treecover2000' ) m.add_layer(forest, {'max': 80}, 'forest cover 30 m') # Get the forest cover data at MODIS scale and projection. forest_mean = ( forest # Force the next reprojection to aggregate instead of resampling. .reduceResolution(reducer=ee.Reducer.mean(), maxPixels=1024) # Request the data at the scale and projection of the MODIS image. .reproject(crs=modis_projection) ) # Display the aggregated, reprojected forest cover data. m.add_layer(forest_mean, {'max': 80}, 'forest cover at MODIS scale')
در این مثال، توجه داشته باشید که تصویرسازی خروجی بهطور صریح با
reproject() تنظیم شده است. During the reprojection to the MODIS
sinusoidal projection, rather than resampling, the smaller pixels are aggregated
with the specified reducer (ee.Reducer.mean() in the example). این توالی
عملیات در شکل ۳ نشان داده شده است. اگرچه این مثال از
reproject() برای کمک به تجسم اثر reduceResolution() استفاده میکند، اکثر دستورگانها
نیازی به بازنمایی صریح ندارند؛ هشدار را
اینجا ببینید.

شکل ۳. نمودار جریان عملیات وقتی reduceResolution() در تصویر ورودی قبلاز reproject() فراخوانی میشود. خطوط منحنی نشاندهنده جریان اطلاعات به بازفرافکنی است: بهطور خاص، فرافکنی خروجی، مقیاس، و روش انبوهش پیکسل برای استفاده.
پهنای پیکسل برای ReduceResolution
وزن پیکسلهای استفادهشده درطول فرایند انبوهش reduceResolution()
براساس همپوشانی بین پیکسلهای کوچکتر درحال انبوهش و
پیکسلهای بزرگتر مشخصشده توسط تصویر خروجی است. این موضوع در شکل ۴ نشان داده شده است.

شکل ۴. پیکسلهای ورودی (سیاه) و پیکسل خروجی (آبی) برای
reduceResolution().
رفتار پیشفرض این است که وزنهای پیکسل ورودی بهعنوان کسری از
مساحت پیکسل خروجی تحت پوشش پیکسل ورودی محاسبه میشوند. در نمودار، پیکسل خروجی دارای مساحت a است، وزن پیکسل ورودی با مساحت تقاطع b بهصورت b/a محاسبه میشود، و وزن پیکسل ورودی با مساحت تقاطع c بهصورت c/a محاسبه میشود. این رفتار میتواند منجر به نتایج غیرمنتظره هنگام استفاده از
کاهندهای غیراز کاهنده میانگین شود. برای مثال، برای محاسبه مساحت جنگلی در هر پیکسل، از کاهنده میانگین برای محاسبه کسر پیکسل پوششدادهشده استفاده کنید، سپس آن را در مساحت ضرب کنید (بهجای محاسبه مساحتها در پیکسلهای کوچکتر و سپس جمع کردن آنها با کاهنده مجموع):
ویرایشگر کد (جاوا اسکریپت)
// Compute forest area per MODIS pixel. var forestArea = forest.gt(0) // Force the next reprojection to aggregate instead of resampling. .reduceResolution({ reducer: ee.Reducer.mean(), maxPixels: 1024 }) // The reduce resolution returns the fraction of the MODIS pixel // that's covered by 30 meter forest pixels. Convert to area // after the reduceResolution() call. .multiply(ee.Image.pixelArea()) // Request the data at the scale and projection of the MODIS image. .reproject({ crs: modisProjection }); Map.addLayer(forestArea, {max: 500 * 500}, 'forested area at MODIS scale');
import ee import geemap.core as geemap
Colab (Python)
# Compute forest area per MODIS pixel. forest_area = ( forest.gt(0) # Force the next reprojection to aggregate instead of resampling. .reduceResolution(reducer=ee.Reducer.mean(), maxPixels=1024) # The reduce resolution returns the fraction of the MODIS pixel # that's covered by 30 meter forest pixels. Convert to area # after the reduceResolution() call. .multiply(ee.Image.pixelArea()) # Request the data at the scale and projection of the MODIS image. .reproject(crs=modis_projection) ) m.add_layer(forest_area, {'max': 500 * 500}, 'forested area at MODIS scale') m