지형지물 및 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()를 사용합니다. 특히 매개변수 pointRadiusstrokeWidth는 렌더링된 FeatureCollection에서 각각 점과 선의 크기를 제어합니다.

코드 편집기 (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()를 사용하세요. 3밴드 8비트 디스플레이 이미지를 출력하는 draw()와 달리 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',
)