ee.Image.sampleRegions

ছবির প্রতিটি পিক্সেলকে (প্রদত্ত স্কেলে) কনভার্ট করে যা এক বা একাধিক অঞ্চলকে একটি ফিচারে ছেদ করে, সেগুলিকে FeatureCollection হিসেবে ফেরত দেয়। প্রতিটি আউটপুট ফিচারে ইনপুট ছবির প্রতিটি ব্যান্ডের জন্য একটি করে প্রপার্টি থাকবে, এর পাশাপাশি ইনপুট ফিচার থেকে কপি করা যেকোনও নির্দিষ্ট প্রপার্টিও থাকবে।

মনে রাখবেন যে জিওমেট্রি পিক্সেল সেন্টারে স্ন্যাপ করা হবে।

ব্যবহাররিটার্ন
Image.sampleRegions(collection, properties, scale, projection, tileScale, geometries)FeatureCollection
আর্গুমেন্টধরনবিবরণ
এটি: imageছবিস্যাম্পেল করার জন্য ছবি।
collectionFeatureCollectionযেসব অঞ্চলে স্যাম্পেল করা হবে।
propertiesতালিকা, ডিফল্ট: nullপ্রতিটি ইনপুট ফিচার থেকে কপি করার জন্য প্রপার্টির তালিকা। ডিফল্ট হিসেবে সব নন-সিস্টেম প্রপার্টিতে সেট করা হয়।
scaleফ্লোট, ডিফল্ট: nullস্যাম্পেল করার জন্য প্রোজেকশনের মিটারে নামমাত্র স্কেল। নির্দিষ্ট করা না থাকলে, ছবির প্রথম ব্যান্ডের স্কেল ব্যবহার করা হয়।
projectionপ্রোজেকশন, ডিফল্ট: nullযে প্রোজেকশনে স্যাম্পেল করতে হবে। নির্দিষ্ট করা না থাকলে, ছবির প্রথম ব্যান্ডের প্রজেকশন ব্যবহার করা হয়। স্কেল ছাড়াও উল্লেখ করা থাকলে, উল্লেখ করা স্কেলে রিস্কেল করা হয়।
tileScaleFloat, ডিফল্ট: ১অ্যাগ্রিগেশন টাইল সাইজ কমাতে ব্যবহৃত একটি স্কেলিং ফ্যাক্টর; একটি বড় tileScale (যেমন, ২ বা ৪) ব্যবহার করলে এমন কম্পিউটেশন চালু হতে পারে যা ডিফল্ট সহ মেমরির বাইরে চলে যায়।
geometriesবুলিয়ান, ডিফল্ট: falseসত্য হলে, ফলাফলে স্যাম্পেল করা পিক্সেল প্রতি একটি পয়েন্ট জিওমেট্রি অন্তর্ভুক্ত থাকবে। অন্যথায়, জ্যামিতি বাদ দেওয়া হবে (মেমরি সেভ করা হচ্ছে)।

উদাহরণ

কোড এডিটর (জাভাস্ক্রিপ্ট)

// A Sentinel-2 surface reflectance image.
var img = ee.Image('COPERNICUS/S2_SR_HARMONIZED/20210109T185751_20210109T185931_T10SEG');
Map.setCenter(-122.503881, 37.765588, 18);
Map.addLayer(img, {bands: ['B11', 'B8', 'B3'], min: 100, max: 4500}, 'img');

// A feature collection with two polygon regions each intersecting 36
// pixels at 10 m scale.
var fcPolygon = ee.FeatureCollection([
  ee.Feature(ee.Geometry.Rectangle(
    -122.50620929, 37.76502806, -122.50552264, 37.76556663), {id: 0}),
  ee.Feature(ee.Geometry.Rectangle(
    -122.50530270, 37.76565568, -122.50460533, 37.76619425), {id: 1})
]);
Map.addLayer(fcPolygon, {color: 'yellow'}, 'fcPolygon');

var fcPolygonSamp = img.sampleRegions({
  collection: fcPolygon,
  scale: 10,
  geometries: true
});
// Note that 7 pixels are missing from the sample. If a pixel contains a masked
// band value it will be excluded from the sample. In this case, the TCI_B band
// is masked for each unsampled pixel.
print('A feature per pixel (at given scale) in each region', fcPolygonSamp);
Map.addLayer(fcPolygonSamp, {color: 'purple'}, 'fcPolygonSamp');

// A feature collection with two points intersecting two different pixels.
// This example is included to show the behavior for point geometries. In
// practice, if the feature collection is all points, ee.Image.reduceRegions
// should be used instead to save memory.
var fcPoint = ee.FeatureCollection([
  ee.Feature(ee.Geometry.Point([-122.50309256, 37.76605006]), {id: 0}),
  ee.Feature(ee.Geometry.Point([-122.50344661, 37.76560903]), {id: 1})
]);
Map.addLayer(fcPoint, {color: 'cyan'}, 'fcPoint');

var fcPointSamp = img.sampleRegions({
  collection: fcPoint,
  scale: 10
});
print('A feature per point', fcPointSamp);

Python সেট-আপ

Python API এবং ইন্টার‍্যাক্টিভ ডেভেলপমেন্টের জন্য geemap ব্যবহার করা সম্পর্কে তথ্যের জন্য Python এনভায়রনমেন্ট পৃষ্ঠা দেখুন।

import ee
import geemap.core as geemap

Colab (Python)

# A Sentinel-2 surface reflectance image.
img = ee.Image('COPERNICUS/S2_SR_HARMONIZED/20210109T185751_20210109T185931_T10SEG')
m = geemap.Map()
m.set_center(-122.503881, 37.765588, 18)
m.add_layer(
    img, {'bands': ['B11', 'B8', 'B3'], 'min': 100, 'max': 4500}, 'img'
)
display(m)

# A feature collection with two polygon regions each intersecting 36
# pixels at 10 m scale.
fc_polygon = ee.FeatureCollection([
    ee.Feature(
        ee.Geometry.Rectangle(
            -122.50620929, 37.76502806, -122.50552264, 37.76556663
        ),
        {'id': 0},
    ),
    ee.Feature(
        ee.Geometry.Rectangle(
            -122.50530270, 37.76565568, -122.50460533, 37.76619425
        ),
        {'id': 1},
    ),
])
m.add_layer(fc_polygon, {'color': 'yellow'}, 'fc_polygon')

fc_polygon_samp = img.sampleRegions(
    collection=fc_polygon, scale=10, geometries=True
)
# Note that 7 pixels are missing from the sample. If a pixel contains a masked
# band value it will be excluded from the sample. In this case, the TCI_B band
# is masked for each unsampled pixel.
display('A feature per pixel (at given scale) in each region', fc_polygon_samp)
m.add_layer(fc_polygon_samp, {'color': 'purple'}, 'fc_polygon_samp')

# A feature collection with two points intersecting two different pixels.
# This example is included to show the behavior for point geometries. In
# practice, if the feature collection is all points, ee.Image.reduceRegions
# should be used instead to save memory.
fc_point = ee.FeatureCollection([
    ee.Feature(ee.Geometry.Point([-122.50309256, 37.76605006]), {'id': 0}),
    ee.Feature(ee.Geometry.Point([-122.50344661, 37.76560903]), {'id': 1}),
])
m.add_layer(fc_point, {'color': 'cyan'}, 'fc_point')

fc_point_samp = img.sampleRegions(collection=fc_point, scale=10)
display('A feature per point', fc_point_samp)