ارسال بازخورد
ee.Image.distance
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
با استفاده از هسته فاصله مشخص شده، فاصله تا نزدیکترین پیکسل غیر صفر را در هر باند محاسبه می کند.
استفاده برمی گرداند Image. distance ( kernel , skipMasked )
تصویر
استدلال تایپ کنید جزئیات این: image
تصویر تصویر ورودی kernel
هسته، پیش فرض: null هسته فاصله. یکی از چبیشف، اقلیدسی یا منهتن. skipMasked
بولی، پیش فرض: درست است اگر پیکسل ورودی مربوطه پوشانده شده باشد، پیکسل های خروجی را ماسک کنید.
نمونه ها ویرایشگر کد (جاوا اسکریپت)
// The objective is to determine the per-pixel distance to a target
// feature (pixel value). In this example, the target feature is water in a
// land cover map.
// Import a Dynamic World land cover image and subset the 'label' band.
var lcImg = ee . Image (
'GOOGLE/DYNAMICWORLD/V1/20210726T171859_20210726T172345_T14TQS' )
. select ( 'label' );
// Create a binary image where the target feature is value 1, all else 0.
// In the Dynamic World map, water is represented as value 0, so we use the
// ee.Image.eq() relational operator to set it to 1.
var targetImg = lcImg . eq ( 0 );
// Set a max distance from target pixels to consider in the analysis. Pixels
// with distance greater than this value from target pixels will be masked out.
// Here, we are using units of meters, but the distance kernels also accept
// units of pixels.
var maxDistM = 10000 ; // 10 km
// Calculate distance to target pixels. Several distance kernels are provided.
// Euclidean distance.
var euclideanKernel = ee . Kernel . euclidean ( maxDistM , 'meters' );
var euclideanDist = targetImg . distance ( euclideanKernel );
var vis = { min : 0 , max : maxDistM };
Map . setCenter ( - 95.68 , 46.46 , 9 );
Map . addLayer ( euclideanDist , vis , 'Euclidean distance to target pixels' );
// Manhattan distance.
var manhattanKernel = ee . Kernel . manhattan ( maxDistM , 'meters' );
var manhattanDist = targetImg . distance ( manhattanKernel );
Map . addLayer ( manhattanDist , vis , 'Manhattan distance to target pixels' , false );
// Chebyshev distance.
var chebyshevKernel = ee . Kernel . chebyshev ( maxDistM , 'meters' );
var chebyshevDist = targetImg . distance ( chebyshevKernel );
Map . addLayer ( chebyshevDist , vis , 'Chebyshev distance to target pixels' , false );
// Add the target layer to the map; water is blue, all else masked out.
Map . addLayer ( targetImg . mask ( targetImg ), { palette : 'blue' }, 'Target pixels' ); راه اندازی پایتون
برای اطلاعات در مورد API پایتون و استفاده از geemap
برای توسعه تعاملی به صفحه محیط پایتون مراجعه کنید.
import ee
import geemap.core as geemap کولب (پایتون)
# The objective is to determine the per-pixel distance to a target
# feature (pixel value). In this example, the target feature is water in a
# land cover map.
# Import a Dynamic World land cover image and subset the 'label' band.
lc_img = ee . Image (
'GOOGLE/DYNAMICWORLD/V1/20210726T171859_20210726T172345_T14TQS'
) . select ( 'label' )
# Create a binary image where the target feature is value 1, all else 0.
# In the Dynamic World map, water is represented as value 0, so we use the
# ee.Image.eq() relational operator to set it to 1.
target_img = lc_img . eq ( 0 )
# Set a max distance from target pixels to consider in the analysis. Pixels
# with distance greater than this value from target pixels will be masked out.
# Here, we are using units of meters, but the distance kernels also accept
# units of pixels.
max_dist_m = 10000 # 10 km
# Calculate distance to target pixels. Several distance kernels are provided.
# Euclidean distance.
euclidean_kernel = ee . Kernel . euclidean ( max_dist_m , 'meters' )
euclidean_dist = target_img . distance ( euclidean_kernel )
vis = { 'min' : 0 , 'max' : max_dist_m }
m = geemap . Map ()
m . set_center ( - 95.68 , 46.46 , 9 )
m . add_layer ( euclidean_dist , vis , 'Euclidean distance to target pixels' )
# Manhattan distance.
manhattan_kernel = ee . Kernel . manhattan ( max_dist_m , 'meters' )
manhattan_dist = target_img . distance ( manhattan_kernel )
m . add_layer (
manhattan_dist , vis , 'Manhattan distance to target pixels' , False
)
# Chebyshev distance.
chebyshev_kernel = ee . Kernel . chebyshev ( max_dist_m , 'meters' )
chebyshev_dist = target_img . distance ( chebyshev_kernel )
m . add_layer (
chebyshev_dist , vis , 'Chebyshev distance to target pixels' , False
)
# Add the target layer to the map water is blue, all else masked out.
m . add_layer (
target_img . mask ( target_img ), { 'palette' : 'blue' }, 'Target pixels'
)
m ،با استفاده از هسته فاصله مشخص شده، فاصله تا نزدیکترین پیکسل غیر صفر را در هر باند محاسبه می کند.
استفاده برمی گرداند Image. distance ( kernel , skipMasked )
تصویر
استدلال تایپ کنید جزئیات این: image
تصویر تصویر ورودی kernel
هسته، پیش فرض: null هسته فاصله. یکی از چبیشف، اقلیدسی یا منهتن. skipMasked
بولی، پیش فرض: درست است اگر پیکسل ورودی مربوطه پوشانده شده باشد، پیکسل های خروجی را ماسک کنید.
نمونه ها ویرایشگر کد (جاوا اسکریپت)
// The objective is to determine the per-pixel distance to a target
// feature (pixel value). In this example, the target feature is water in a
// land cover map.
// Import a Dynamic World land cover image and subset the 'label' band.
var lcImg = ee . Image (
'GOOGLE/DYNAMICWORLD/V1/20210726T171859_20210726T172345_T14TQS' )
. select ( 'label' );
// Create a binary image where the target feature is value 1, all else 0.
// In the Dynamic World map, water is represented as value 0, so we use the
// ee.Image.eq() relational operator to set it to 1.
var targetImg = lcImg . eq ( 0 );
// Set a max distance from target pixels to consider in the analysis. Pixels
// with distance greater than this value from target pixels will be masked out.
// Here, we are using units of meters, but the distance kernels also accept
// units of pixels.
var maxDistM = 10000 ; // 10 km
// Calculate distance to target pixels. Several distance kernels are provided.
// Euclidean distance.
var euclideanKernel = ee . Kernel . euclidean ( maxDistM , 'meters' );
var euclideanDist = targetImg . distance ( euclideanKernel );
var vis = { min : 0 , max : maxDistM };
Map . setCenter ( - 95.68 , 46.46 , 9 );
Map . addLayer ( euclideanDist , vis , 'Euclidean distance to target pixels' );
// Manhattan distance.
var manhattanKernel = ee . Kernel . manhattan ( maxDistM , 'meters' );
var manhattanDist = targetImg . distance ( manhattanKernel );
Map . addLayer ( manhattanDist , vis , 'Manhattan distance to target pixels' , false );
// Chebyshev distance.
var chebyshevKernel = ee . Kernel . chebyshev ( maxDistM , 'meters' );
var chebyshevDist = targetImg . distance ( chebyshevKernel );
Map . addLayer ( chebyshevDist , vis , 'Chebyshev distance to target pixels' , false );
// Add the target layer to the map; water is blue, all else masked out.
Map . addLayer ( targetImg . mask ( targetImg ), { palette : 'blue' }, 'Target pixels' ); راه اندازی پایتون
برای اطلاعات در مورد API پایتون و استفاده از geemap
برای توسعه تعاملی به صفحه محیط پایتون مراجعه کنید.
import ee
import geemap.core as geemap کولب (پایتون)
# The objective is to determine the per-pixel distance to a target
# feature (pixel value). In this example, the target feature is water in a
# land cover map.
# Import a Dynamic World land cover image and subset the 'label' band.
lc_img = ee . Image (
'GOOGLE/DYNAMICWORLD/V1/20210726T171859_20210726T172345_T14TQS'
) . select ( 'label' )
# Create a binary image where the target feature is value 1, all else 0.
# In the Dynamic World map, water is represented as value 0, so we use the
# ee.Image.eq() relational operator to set it to 1.
target_img = lc_img . eq ( 0 )
# Set a max distance from target pixels to consider in the analysis. Pixels
# with distance greater than this value from target pixels will be masked out.
# Here, we are using units of meters, but the distance kernels also accept
# units of pixels.
max_dist_m = 10000 # 10 km
# Calculate distance to target pixels. Several distance kernels are provided.
# Euclidean distance.
euclidean_kernel = ee . Kernel . euclidean ( max_dist_m , 'meters' )
euclidean_dist = target_img . distance ( euclidean_kernel )
vis = { 'min' : 0 , 'max' : max_dist_m }
m = geemap . Map ()
m . set_center ( - 95.68 , 46.46 , 9 )
m . add_layer ( euclidean_dist , vis , 'Euclidean distance to target pixels' )
# Manhattan distance.
manhattan_kernel = ee . Kernel . manhattan ( max_dist_m , 'meters' )
manhattan_dist = target_img . distance ( manhattan_kernel )
m . add_layer (
manhattan_dist , vis , 'Manhattan distance to target pixels' , False
)
# Chebyshev distance.
chebyshev_kernel = ee . Kernel . chebyshev ( max_dist_m , 'meters' )
chebyshev_dist = target_img . distance ( chebyshev_kernel )
m . add_layer (
chebyshev_dist , vis , 'Chebyshev distance to target pixels' , False
)
# Add the target layer to the map water is blue, all else masked out.
m . add_layer (
target_img . mask ( target_img ), { 'palette' : 'blue' }, 'Target pixels'
)
m
ارسال بازخورد
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-24 بهوقت ساعت هماهنگ جهانی.
میخواهید موارد بیشتری را با ما درمیان بگذارید؟
[[["درک آسان","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-24 بهوقت ساعت هماهنگ جهانی."],[],[],null,[]]