ee.Image.sampleRegions
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
यह फ़ंक्शन, किसी इमेज के हर पिक्सल को (दिए गए स्केल पर) एक सुविधा में बदलता है. यह पिक्सल, एक या उससे ज़्यादा क्षेत्रों को काटता है और उन्हें FeatureCollection के तौर पर दिखाता है. हर आउटपुट फ़ीचर में, इनपुट इमेज के हर बैंड के लिए एक प्रॉपर्टी होगी. साथ ही, इनपुट फ़ीचर से कॉपी की गई कोई भी प्रॉपर्टी होगी.
ध्यान दें कि ज्यामिति को पिक्सल सेंटर पर स्नैप किया जाएगा.
इस्तेमाल | रिटर्न |
---|
Image.sampleRegions(collection, properties, scale, projection, tileScale, geometries) | FeatureCollection |
आर्ग्यूमेंट | टाइप | विवरण |
---|
यह: image | इमेज | वह इमेज जिसका सैंपल लेना है. |
collection | FeatureCollection | वे इलाके जहां से सैंपल लेना है. |
properties | सूची, डिफ़ॉल्ट: null | हर इनपुट सुविधा से कॉपी की जाने वाली प्रॉपर्टी की सूची. डिफ़ॉल्ट रूप से, यह सभी नॉन-सिस्टम प्रॉपर्टी के लिए लागू होता है. |
scale | फ़्लोट, डिफ़ॉल्ट: null | यह प्रोजेक्शन का नॉमिनल स्केल है, जिसे मीटर में मापा जाता है. इसका इस्तेमाल सैंपल लेने के लिए किया जाता है. अगर यह जानकारी नहीं दी जाती है, तो इमेज के पहले बैंड के स्केल का इस्तेमाल किया जाता है. |
projection | प्रोजेक्शन, डिफ़ॉल्ट: null | वह प्रोजेक्शन जिसमें सैंपल लेना है. अगर यह जानकारी नहीं दी जाती है, तो इमेज के पहले बैंड के प्रोजेक्शन का इस्तेमाल किया जाता है. अगर इसे स्केल के अलावा किसी और एट्रिब्यूट में बताया गया है, तो इसे बताई गई स्केल के हिसाब से फिर से स्केल किया जाता है. |
tileScale | फ़्लोट, डिफ़ॉल्ट: 1 | एग्रीगेशन टाइल के साइज़ को कम करने के लिए इस्तेमाल किया जाने वाला स्केलिंग फ़ैक्टर; tileScale का बड़ा मान इस्तेमाल करने पर (जैसे, 2 या 4) डिफ़ॉल्ट वैल्यू के साथ, मेमोरी से बाहर की गणनाएं चालू कर सकते हैं. |
geometries | बूलियन, डिफ़ॉल्ट वैल्यू: false | अगर इस विकल्प को 'सही है' पर सेट किया जाता है, तो नतीजों में सैंपल किए गए हर पिक्सल के लिए एक पॉइंट ज्यामिति शामिल होगी. ऐसा न करने पर, ज्यामिति को शामिल नहीं किया जाएगा. इससे मेमोरी बचेगी. |
उदाहरण
कोड एडिटर (JavaScript)
// A Sentinel-2 surface reflectance image.
var img = ee.Image('COPERNICUS/S2_SR/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/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)
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-07-26 (UTC) को अपडेट किया गया."],[],["The `Image.sampleRegions` method converts image pixels intersecting specified regions into a `FeatureCollection`. Each output feature contains properties from the input image bands and any designated input feature properties. Geometries are snapped to pixel centers. The sampling scale and projection can be specified; otherwise, the image's first band defaults are used. Optionally, geometries of the sampled pixels can be included, and tile scaling can be used for memory management.\n"],null,[]]