Feature और FeatureCollection का विज़ुअलाइज़ेशन

इमेज, ज्यामिति, और सुविधाओं की तरह ही, सुविधाओं के कलेक्शन को मैप में सीधे Map.addLayer() का इस्तेमाल करके जोड़ा जा सकता है. डिफ़ॉल्ट विज़ुअलाइज़ेशन में, वैक्टर को पूरी तरह काली रेखाओं और आधा पारदर्शी काले रंग के साथ दिखाया जाएगा. वेक्टर को रंग में रेंडर करने के लिए, color पैरामीटर की वैल्यू डालें. यहां 'RESOLVE' इको-क्षेत्र (Dinerstein et al. 2017) को डिफ़ॉल्ट विज़ुअलाइज़ेशन के तौर पर और लाल रंग में दिखाया गया है:

कोड एडिटर (JavaScript)

// Load a FeatureCollection from a table dataset: 'RESOLVE' ecoregions.
var ecoregions = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017');

// Display as default and with a custom color.
Map.addLayer(ecoregions, {}, 'default display');
Map.addLayer(ecoregions, {color: 'FF0000'}, 'colored');

Python सेटअप

Python API के बारे में जानकारी पाने और इंटरैक्टिव डेवलपमेंट के लिए geemap का इस्तेमाल करने के लिए, Python एनवायरमेंट पेज देखें.

import ee
import geemap.core as geemap

Colab (Python)

# Load a FeatureCollection from a table dataset: 'RESOLVE' ecoregions.
ecoregions = ee.FeatureCollection('RESOLVE/ECOREGIONS/2017')

# Display as default and with a custom color.
m = geemap.Map()
m.set_center(-76.2486, 44.8988, 8)
m.add_layer(ecoregions, {}, 'default display')
m.add_layer(ecoregions, {'color': 'FF0000'}, 'colored')
m

डिसप्ले के अन्य विकल्पों के लिए, featureCollection.draw() का इस्तेमाल करें. खास तौर पर, रेंडर किए गए FeatureCollection में, पैरामीटर pointRadius और strokeWidth, पॉइंट और लाइनों के साइज़ को कंट्रोल करते हैं:

कोड एडिटर (JavaScript)

Map.addLayer(ecoregions.draw({color: '006600', strokeWidth: 5}), {}, 'drawn');

Python सेटअप

Python API के बारे में जानकारी पाने और इंटरैक्टिव डेवलपमेंट के लिए geemap का इस्तेमाल करने के लिए, Python एनवायरमेंट पेज देखें.

import ee
import geemap.core as geemap

Colab (Python)

m.add_layer(ecoregions.draw(color='006600', strokeWidth=5), {}, 'drawn')

draw() का आउटपुट, color पैरामीटर के हिसाब से सेट किए गए लाल, हरे, और नीले रंग के बैंड वाली इमेज होती है.

FeatureCollection को दिखाने के तरीके को ज़्यादा कंट्रोल करने के लिए, FeatureCollection को आर्ग्युमेंट के तौर पर इस्तेमाल करें.image.paint() draw(), तीन-बैंड वाली 8-बिट डिसप्ले इमेज दिखाता है. इसके उलट, image.paint() में दी गई संख्या वाली वैल्यू को 'पेंट' करके इमेज दिखाता है. इसके अलावा, FeatureCollection में किसी ऐसी प्रॉपर्टी का नाम दिया जा सकता है जिसमें पेंट करने के लिए संख्याएं हों. width पैरामीटर भी इसी तरह काम करता है: यह एक कॉन्स्टेंट हो सकता है या लाइन की चौड़ाई के लिए, संख्या वाली प्रॉपर्टी का नाम हो सकता है. उदाहरण के लिए:

कोड एडिटर (JavaScript)

// Create an empty image into which to paint the features, cast to byte.
var empty = ee.Image().byte();

// Paint all the polygon edges with the same number and width, display.
var outline = empty.paint({
  featureCollection: ecoregions,
  color: 1,
  width: 3
});
Map.addLayer(outline, {palette: 'FF0000'}, 'edges');

Python सेटअप

Python API के बारे में जानकारी पाने और इंटरैक्टिव डेवलपमेंट के लिए geemap का इस्तेमाल करने के लिए, Python एनवायरमेंट पेज देखें.

import ee
import geemap.core as geemap

Colab (Python)

# Create an empty image into which to paint the features, cast to byte.
empty = ee.Image().byte()

# Paint all the polygon edges with the same number and width, display.
outline = empty.paint(featureCollection=ecoregions, color=1, width=3)
m.add_layer(outline, {'palette': 'FF0000'}, 'edges')

ध्यान दें कि जिस खाली इमेज में आपको सुविधाएं पेंट करनी हैं उसे पेंट करने से पहले, कास्ट करना ज़रूरी है. ऐसा इसलिए होता है, क्योंकि एक कॉन्स्टेंट इमेज, कॉन्स्टेंट की तरह काम करती है: इसे शुरू करने की वैल्यू पर क्लैंप किया जाता है. किसी प्रॉपर्टी से सेट की गई वैल्यू के साथ, फीचर के किनारों को रंग देने के लिए, रंग पैरामीटर को संख्या वाली वैल्यू वाली प्रॉपर्टी के नाम पर सेट करें:

कोड एडिटर (JavaScript)

// Paint the edges with different colors, display.
var outlines = empty.paint({
  featureCollection: ecoregions,
  color: 'BIOME_NUM',
  width: 4
});
var palette = ['FF0000', '00FF00', '0000FF'];
Map.addLayer(outlines, {palette: palette, max: 14}, 'different color edges');

Python सेटअप

Python API के बारे में जानकारी पाने और इंटरैक्टिव डेवलपमेंट के लिए geemap का इस्तेमाल करने के लिए, Python एनवायरमेंट पेज देखें.

import ee
import geemap.core as geemap

Colab (Python)

# Paint the edges with different colors, display.
outlines = empty.paint(featureCollection=ecoregions, color='BIOME_NUM', width=4)
palette = ['FF0000', '00FF00', '0000FF']
m.add_layer(outlines, {'palette': palette, 'max': 14}, 'different color edges')

प्रॉपर्टी की मदद से, बॉर्डर के रंग और चौड़ाई, दोनों को सेट किया जा सकता है. उदाहरण के लिए:

कोड एडिटर (JavaScript)

// Paint the edges with different colors and widths.
var outlines = empty.paint({
  featureCollection: ecoregions,
  color: 'BIOME_NUM',
  width: 'NNH'
});
Map.addLayer(outlines, {palette: palette, max: 14}, 'different color, width edges');

Python सेटअप

Python API के बारे में जानकारी पाने और इंटरैक्टिव डेवलपमेंट के लिए geemap का इस्तेमाल करने के लिए, Python एनवायरमेंट पेज देखें.

import ee
import geemap.core as geemap

Colab (Python)

# Paint the edges with different colors and widths.
outlines = empty.paint(
    featureCollection=ecoregions, color='BIOME_NUM', width='NNH'
)
m.add_layer(
    outlines, {'palette': palette, 'max': 14}, 'different color, width edges'
)

अगर width पैरामीटर नहीं दिया गया है, तो सुविधाओं के अंदरूनी हिस्से को रंगा जाता है:

कोड एडिटर (JavaScript)

// Paint the interior of the polygons with different colors.
var fills = empty.paint({
  featureCollection: ecoregions,
  color: 'BIOME_NUM',
});
Map.addLayer(fills, {palette: palette, max: 14}, 'colored fills');

Python सेटअप

Python API के बारे में जानकारी पाने और इंटरैक्टिव डेवलपमेंट के लिए geemap का इस्तेमाल करने के लिए, Python एनवायरमेंट पेज देखें.

import ee
import geemap.core as geemap

Colab (Python)

# Paint the interior of the polygons with different colors.
fills = empty.paint(featureCollection=ecoregions, color='BIOME_NUM')
m.add_layer(fills, {'palette': palette, 'max': 14}, 'colored fills')

सुविधाओं के अंदरूनी हिस्से और किनारों, दोनों को रेंडर करने के लिए, खाली इमेज को दो बार पेंट करें:

कोड एडिटर (JavaScript)

// Paint both the fill and the edges.
var filledOutlines = empty.paint(ecoregions, 'BIOME_NUM').paint(ecoregions, 0, 2);
Map.addLayer(filledOutlines, {palette: ['000000'].concat(palette), max: 14}, 'edges and fills');

Python सेटअप

Python API के बारे में जानकारी पाने और इंटरैक्टिव डेवलपमेंट के लिए geemap का इस्तेमाल करने के लिए, Python एनवायरमेंट पेज देखें.

import ee
import geemap.core as geemap

Colab (Python)

# Paint both the fill and the edges.
filled_outlines = empty.paint(ecoregions, 'BIOME_NUM').paint(ecoregions, 0, 2)
m.add_layer(
    filled_outlines,
    {'palette': ['000000'] + palette, 'max': 14},
    'edges and fills',
)