ee.Image.sample

একটি চিত্রের পিক্সেলের নমুনা দেয়, সেগুলিকে ফিচার কালেকশন হিসেবে ফিরিয়ে দেয়। ইনপুট ইমেজে প্রতিটি বৈশিষ্ট্যে প্রতি ব্যান্ডে 1টি বৈশিষ্ট্য থাকবে। মনে রাখবেন যে ডিফল্ট আচরণ হল এমন বৈশিষ্ট্যগুলি বাদ দেওয়া যা মুখোশযুক্ত পিক্সেলগুলিকে ছেদ করে, যার ফলে নাল-মূল্যের বৈশিষ্ট্য হয় (ড্রপনুলস আর্গুমেন্ট দেখুন)।

ব্যবহার রিটার্নস
Image. sample ( region , scale , projection , factor , numPixels , seed , dropNulls , tileScale , geometries ) ফিচার কালেকশন
যুক্তি টাইপ বিস্তারিত
এই: image ছবি নমুনা ইমেজ.
region জ্যামিতি, ডিফল্ট: নাল যে অঞ্চল থেকে নমুনা নেওয়া হবে। অনির্দিষ্ট থাকলে, ছবির পুরো পদচিহ্ন ব্যবহার করুন।
scale ফ্লোট, ডিফল্ট: নাল নমুনা ইন প্রজেকশনের মিটারে একটি নামমাত্র স্কেল।
projection অভিক্ষেপ, ডিফল্ট: নাল নমুনা যা অভিক্ষেপ. অনির্দিষ্ট হলে, ছবির প্রথম ব্যান্ডের অভিক্ষেপ ব্যবহার করা হয়। স্কেল ছাড়াও নির্দিষ্ট করা হলে, নির্দিষ্ট স্কেলে রিস্কেল করা হয়।
factor ফ্লোট, ডিফল্ট: নাল একটি সাবস্যাম্পলিং ফ্যাক্টর, (0, 1] এর মধ্যে। নির্দিষ্ট করা থাকলে, 'numPixels' অবশ্যই নির্দিষ্ট করা যাবে না। কোনো সাবস্যাম্পলিং না হলে ডিফল্ট।
numPixels দীর্ঘ, ডিফল্ট: নাল নমুনার জন্য পিক্সেলের আনুমানিক সংখ্যা। নির্দিষ্ট করা হলে, 'ফ্যাক্টর' অবশ্যই নির্দিষ্ট করা যাবে না।
seed পূর্ণসংখ্যা, ডিফল্ট: 0 সাবস্যাম্পলিং এর জন্য ব্যবহার করার জন্য একটি এলোমেলোকরণ বীজ।
dropNulls বুলিয়ান, ডিফল্ট: সত্য শূন্য-মূল্যবান বৈশিষ্ট্য রয়েছে এমন বৈশিষ্ট্যগুলি বাদ দিতে ফলাফলটি ফিল্টার পোস্ট করুন।
tileScale ফ্লোট, ডিফল্ট: 1 অ্যাগ্রিগেশন টাইলের আকার কমাতে ব্যবহৃত একটি স্কেলিং ফ্যাক্টর; একটি বৃহত্তর টাইলস্কেল ব্যবহার করে (যেমন, 2 বা 4) ডিফল্ট সহ মেমরি ফুরিয়ে যাওয়া গণনা সক্ষম করতে পারে।
geometries বুলিয়ান, ডিফল্ট: মিথ্যা সত্য হলে, আউটপুট বৈশিষ্ট্যের জ্যামিতি বৈশিষ্ট্য হিসাবে নমুনাযুক্ত পিক্সেলের কেন্দ্র যোগ করে। অন্যথায়, জ্যামিতি বাদ দেওয়া হবে (মেমরি সংরক্ষণ)।

উদাহরণ

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

// Demonstrate extracting pixels from an image as features with
// ee.Image.sample(), and show how the features are aligned with the pixels.

// An image with one band of elevation data.
var image = ee.Image('CGIAR/SRTM90_V4');
var VIS_MIN = 1620;
var VIS_MAX = 1650;
Map.addLayer(image, {min: VIS_MIN, max: VIS_MAX}, 'SRTM');

// Region to sample.
var region = ee.Geometry.Polygon(
  [[[-110.006, 40.002],
    [-110.006, 39.999],
    [-109.995, 39.999],
    [-109.995, 40.002]]], null, false);
// Show region on the map.
Map.setCenter(-110, 40, 16);
Map.addLayer(ee.FeatureCollection([region]).style({"color": "00FF0022"}));

// Perform sampling; convert image pixels to features.
var samples = image.sample({
  region: region,

  // Default (false) is no geometries in the output.
  // When set to true, each feature has a Point geometry at the center of the
  // image pixel.
  geometries: true,

  // The scale is not specified, so the resolution of the image will be used,
  // and there is a feature for every pixel. If we give a scale parameter, the
  // image will be resampled and there will be more or fewer features.
  //
  // scale: 200,
});

// Visualize sample data using ee.FeatureCollection.style().
var styled = samples
  .map(function (feature) {
    return feature.set('style', {
      pointSize: feature.getNumber('elevation').unitScale(VIS_MIN, VIS_MAX)
          .multiply(15),
    });
  })
  .style({
    color: '000000FF',
    fillColor: '00000000',
    styleProperty: 'style',
    neighborhood: 6,  // increase to correctly draw large points
  });
Map.addLayer(styled);

// Each sample feature has a point geometry and a property named 'elevation'
// corresponding to the band named 'elevation' of the image. If there are
// multiple bands they will become multiple properties. This will print:
//
// geometry: Point (-110.01, 40.00)
// properties:
//   elevation: 1639
print(samples.first());

পাইথন সেটআপ

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

import ee
import geemap.core as geemap

Colab (পাইথন)

# Demonstrate extracting pixels from an image as features with
# ee.Image.sample(), and show how the features are aligned with the pixels.

# An image with one band of elevation data.
image = ee.Image('CGIAR/SRTM90_V4')
vis_min = 1620
vis_max = 1650
m = geemap.Map()
m.add_layer(image, {'min': vis_min, 'max': vis_max}, 'SRTM')

# Region to sample.
region = ee.Geometry.Polygon(
    [[
        [-110.006, 40.002],
        [-110.006, 39.999],
        [-109.995, 39.999],
        [-109.995, 40.002],
    ]],
    None,
    False,
)
# Show region on the map.
m.set_center(-110, 40, 16)

m.add_layer(ee.FeatureCollection([region]).style(color='00FF0022'))

# Perform sampling convert image pixels to features.
samples = image.sample(
    region=region,
    # Default (False) is no geometries in the output.
    # When set to True, each feature has a Point geometry at the center of the
    # image pixel.
    geometries=True,
    # The scale is not specified, so the resolution of the image will be used,
    # and there is a feature for every pixel. If we give a scale parameter, the
    # image will be resampled and there will be more or fewer features.
    #
    # scale=200,
)


def scale_point_size(feature):
  elevation = feature.getNumber('elevation')
  point_size = elevation.unitScale(vis_min, vis_max).multiply(15)
  feature.set('style', {'pointSize': point_size})
  return feature


# Visualize sample data using ee.FeatureCollection.style().
styled = samples.map(scale_point_size).style(
    color='000000FF',
    fillColor='00000000',
    styleProperty='style',
    neighborhood=6,  # increase to correctly draw large points
)
m.add_layer(styled)
display(m)

# Each sample feature has a point geometry and a property named 'elevation'
# corresponding to the band named 'elevation' of the image. If there are
# multiple bands they will become multiple properties. This will print:
#
# geometry: Point (-110.01, 40.00)
# properties:
#   elevation: 1639
display(samples.first())
,একটি চিত্রের পিক্সেলের নমুনা দেয়, সেগুলিকে ফিচার কালেকশন হিসেবে ফিরিয়ে দেয়। ইনপুট ইমেজে প্রতিটি বৈশিষ্ট্যে প্রতি ব্যান্ডে 1টি বৈশিষ্ট্য থাকবে। মনে রাখবেন যে ডিফল্ট আচরণ হল এমন বৈশিষ্ট্যগুলি বাদ দেওয়া যা মুখোশযুক্ত পিক্সেলগুলিকে ছেদ করে, যার ফলে নাল-মূল্যের বৈশিষ্ট্য হয় (ড্রপনুলস আর্গুমেন্ট দেখুন)।

ব্যবহার রিটার্নস
Image. sample ( region , scale , projection , factor , numPixels , seed , dropNulls , tileScale , geometries ) ফিচার কালেকশন
যুক্তি টাইপ বিস্তারিত
এই: image ছবি নমুনা ইমেজ.
region জ্যামিতি, ডিফল্ট: নাল যে অঞ্চল থেকে নমুনা নেওয়া হবে। অনির্দিষ্ট থাকলে, ছবির পুরো পদচিহ্ন ব্যবহার করুন।
scale ফ্লোট, ডিফল্ট: নাল নমুনা ইন প্রজেকশনের মিটারে একটি নামমাত্র স্কেল।
projection অভিক্ষেপ, ডিফল্ট: নাল নমুনা যা অভিক্ষেপ. অনির্দিষ্ট হলে, ছবির প্রথম ব্যান্ডের অভিক্ষেপ ব্যবহার করা হয়। স্কেল ছাড়াও নির্দিষ্ট করা হলে, নির্দিষ্ট স্কেলে রিস্কেল করা হয়।
factor ফ্লোট, ডিফল্ট: নাল একটি সাবস্যাম্পলিং ফ্যাক্টর, (0, 1] এর মধ্যে। নির্দিষ্ট করা থাকলে, 'numPixels' অবশ্যই নির্দিষ্ট করা যাবে না। কোনো সাবস্যাম্পলিং না হলে ডিফল্ট।
numPixels দীর্ঘ, ডিফল্ট: নাল নমুনার জন্য পিক্সেলের আনুমানিক সংখ্যা। নির্দিষ্ট করা হলে, 'ফ্যাক্টর' অবশ্যই নির্দিষ্ট করা যাবে না।
seed পূর্ণসংখ্যা, ডিফল্ট: 0 সাবস্যাম্পলিং এর জন্য ব্যবহার করার জন্য একটি এলোমেলোকরণ বীজ।
dropNulls বুলিয়ান, ডিফল্ট: সত্য শূন্য-মূল্যবান বৈশিষ্ট্য রয়েছে এমন বৈশিষ্ট্যগুলি বাদ দিতে ফলাফলটি ফিল্টার পোস্ট করুন।
tileScale ফ্লোট, ডিফল্ট: 1 অ্যাগ্রিগেশন টাইলের আকার কমাতে ব্যবহৃত একটি স্কেলিং ফ্যাক্টর; একটি বৃহত্তর টাইলস্কেল ব্যবহার করে (যেমন, 2 বা 4) ডিফল্ট সহ মেমরি ফুরিয়ে যাওয়া গণনা সক্ষম করতে পারে।
geometries বুলিয়ান, ডিফল্ট: মিথ্যা সত্য হলে, আউটপুট বৈশিষ্ট্যের জ্যামিতি বৈশিষ্ট্য হিসাবে নমুনাযুক্ত পিক্সেলের কেন্দ্র যোগ করে। অন্যথায়, জ্যামিতি বাদ দেওয়া হবে (মেমরি সংরক্ষণ)।

উদাহরণ

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

// Demonstrate extracting pixels from an image as features with
// ee.Image.sample(), and show how the features are aligned with the pixels.

// An image with one band of elevation data.
var image = ee.Image('CGIAR/SRTM90_V4');
var VIS_MIN = 1620;
var VIS_MAX = 1650;
Map.addLayer(image, {min: VIS_MIN, max: VIS_MAX}, 'SRTM');

// Region to sample.
var region = ee.Geometry.Polygon(
  [[[-110.006, 40.002],
    [-110.006, 39.999],
    [-109.995, 39.999],
    [-109.995, 40.002]]], null, false);
// Show region on the map.
Map.setCenter(-110, 40, 16);
Map.addLayer(ee.FeatureCollection([region]).style({"color": "00FF0022"}));

// Perform sampling; convert image pixels to features.
var samples = image.sample({
  region: region,

  // Default (false) is no geometries in the output.
  // When set to true, each feature has a Point geometry at the center of the
  // image pixel.
  geometries: true,

  // The scale is not specified, so the resolution of the image will be used,
  // and there is a feature for every pixel. If we give a scale parameter, the
  // image will be resampled and there will be more or fewer features.
  //
  // scale: 200,
});

// Visualize sample data using ee.FeatureCollection.style().
var styled = samples
  .map(function (feature) {
    return feature.set('style', {
      pointSize: feature.getNumber('elevation').unitScale(VIS_MIN, VIS_MAX)
          .multiply(15),
    });
  })
  .style({
    color: '000000FF',
    fillColor: '00000000',
    styleProperty: 'style',
    neighborhood: 6,  // increase to correctly draw large points
  });
Map.addLayer(styled);

// Each sample feature has a point geometry and a property named 'elevation'
// corresponding to the band named 'elevation' of the image. If there are
// multiple bands they will become multiple properties. This will print:
//
// geometry: Point (-110.01, 40.00)
// properties:
//   elevation: 1639
print(samples.first());

পাইথন সেটআপ

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

import ee
import geemap.core as geemap

Colab (পাইথন)

# Demonstrate extracting pixels from an image as features with
# ee.Image.sample(), and show how the features are aligned with the pixels.

# An image with one band of elevation data.
image = ee.Image('CGIAR/SRTM90_V4')
vis_min = 1620
vis_max = 1650
m = geemap.Map()
m.add_layer(image, {'min': vis_min, 'max': vis_max}, 'SRTM')

# Region to sample.
region = ee.Geometry.Polygon(
    [[
        [-110.006, 40.002],
        [-110.006, 39.999],
        [-109.995, 39.999],
        [-109.995, 40.002],
    ]],
    None,
    False,
)
# Show region on the map.
m.set_center(-110, 40, 16)

m.add_layer(ee.FeatureCollection([region]).style(color='00FF0022'))

# Perform sampling convert image pixels to features.
samples = image.sample(
    region=region,
    # Default (False) is no geometries in the output.
    # When set to True, each feature has a Point geometry at the center of the
    # image pixel.
    geometries=True,
    # The scale is not specified, so the resolution of the image will be used,
    # and there is a feature for every pixel. If we give a scale parameter, the
    # image will be resampled and there will be more or fewer features.
    #
    # scale=200,
)


def scale_point_size(feature):
  elevation = feature.getNumber('elevation')
  point_size = elevation.unitScale(vis_min, vis_max).multiply(15)
  feature.set('style', {'pointSize': point_size})
  return feature


# Visualize sample data using ee.FeatureCollection.style().
styled = samples.map(scale_point_size).style(
    color='000000FF',
    fillColor='00000000',
    styleProperty='style',
    neighborhood=6,  # increase to correctly draw large points
)
m.add_layer(styled)
display(m)

# Each sample feature has a point geometry and a property named 'elevation'
# corresponding to the band named 'elevation' of the image. If there are
# multiple bands they will become multiple properties. This will print:
#
# geometry: Point (-110.01, 40.00)
# properties:
#   elevation: 1639
display(samples.first())