이미지 시각화

이미지 데이터의 RGB 시각적 표현을 생성하는 여러 ee.Image 메서드가 있습니다. 예를 들면 visualize(), getThumbURL(), getMap(), getMapId()(Colab Folium 지도 표시에 사용됨), Map.addLayer()(코드 편집기 지도 표시에 사용되며 Python에서는 사용할 수 없음)가 있습니다. 기본적으로 이러한 메서드는 처음 세 개의 밴드를 각각 빨간색, 녹색, 파란색에 할당합니다. 기본 스트레치는 밴드의 데이터 유형을 기반으로 합니다(예: 부동 소수점은 [0, 1]로 스트레치되고 16비트 데이터는 가능한 값의 전체 범위로 스트레치됨). 이는 적합할 수도 있고 적합하지 않을 수도 있습니다. 원하는 시각화 효과를 얻으려면 시각화 매개변수를 제공하면 됩니다.

이미지 시각화 매개변수
매개변수 설명 유형
밴드 RGB에 매핑할 쉼표로 구분된 세 개의 밴드 이름 목록입니다. list
min 0에 매핑할 값 숫자 또는 숫자 3개 목록(각 밴드당 하나씩)
max 255에 매핑할 값 숫자 또는 숫자 3개 목록(각 밴드당 하나씩)
gain 각 픽셀 값에 곱할 값 숫자 또는 숫자 3개 목록(각 밴드당 하나씩)
편향 각 DN에 추가할 값 숫자 또는 숫자 3개 목록(각 밴드당 하나씩)
gamma 감마 보정 계수 숫자 또는 숫자 3개 목록(각 밴드당 하나씩)
palette CSS 스타일 색상 문자열 목록(단일 대역 이미지 전용) 쉼표로 구분된 16진수 문자열 목록
opacity 레이어의 불투명도(0.0은 완전 투명, 1.0은 완전 불투명) 숫자
서식 'jpg' 또는 'png' 문자열

RGB 합성

다음은 매개변수를 사용하여 Landsat 8 이미지를 거짓 색상 합성으로 스타일 지정하는 방법을 보여줍니다.

코드 편집기(JavaScript)

// Load an image.
var image = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318');

// Define the visualization parameters.
var vizParams = {
  bands: ['B5', 'B4', 'B3'],
  min: 0,
  max: 0.5,
  gamma: [0.95, 1.1, 1]
};

// Center the map and display the image.
Map.setCenter(-122.1899, 37.5010, 10); // San Francisco Bay
Map.addLayer(image, vizParams, 'false color composite');

Python 설정

Python API 및 대화형 개발을 위한 geemap 사용에 대한 자세한 내용은 Python 환경 페이지를 참조하세요.

import ee
import geemap.core as geemap

Colab(Python)

# Load an image.
image = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318')

# Define the visualization parameters.
image_viz_params = {
    'bands': ['B5', 'B4', 'B3'],
    'min': 0,
    'max': 0.5,
    'gamma': [0.95, 1.1, 1],
}

# Define a map centered on San Francisco Bay.
map_l8 = geemap.Map(center=[37.5010, -122.1899], zoom=10)

# Add the image layer to the map and display it.
map_l8.add_layer(image, image_viz_params, 'false color composite')
display(map_l8)

이 예시에서 밴드 'B5'은 빨간색에, 'B4'은 녹색에, 'B3'은 파란색에 할당됩니다.

false_color_sf
미국 캘리포니아 샌프란시스코 베이 지역의 Landsat 8 위색 합성 이미지

색상 팔레트

이미지의 단일 밴드를 컬러로 표시하려면 CSS 스타일 색상 문자열 목록으로 표현된 색상 램프로 palette 매개변수를 설정합니다. 자세한 내용은 이 참조를 확인하세요. 다음 예시에서는 시안('00FFFF')에서 파란색('0000FF')까지의 색상을 사용하여 정규화 차이 수분 지수(NDWI) 이미지를 렌더링하는 방법을 보여줍니다.

코드 편집기(JavaScript)

// Load an image.
var image = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318');

// Create an NDWI image, define visualization parameters and display.
var ndwi = image.normalizedDifference(['B3', 'B5']);
var ndwiViz = {min: 0.5, max: 1, palette: ['00FFFF', '0000FF']};
Map.addLayer(ndwi, ndwiViz, 'NDWI', false);

Python 설정

Python API 및 대화형 개발을 위한 geemap 사용에 대한 자세한 내용은 Python 환경 페이지를 참조하세요.

import ee
import geemap.core as geemap

Colab(Python)

# Load an image.
image = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_044034_20140318')

# Create an NDWI image, define visualization parameters and display.
ndwi = image.normalizedDifference(['B3', 'B5'])
ndwi_viz = {'min': 0.5, 'max': 1, 'palette': ['00FFFF', '0000FF']}

# Define a map centered on San Francisco Bay.
map_ndwi = geemap.Map(center=[37.5010, -122.1899], zoom=10)

# Add the image layer to the map and display it.
map_ndwi.add_layer(ndwi, ndwi_viz, 'NDWI')
display(map_ndwi)

이 예시에서 min 및 max 매개변수는 팔레트를 적용해야 하는 픽셀 값의 범위를 나타냅니다. 중간 값은 선형으로 확장됩니다.

또한 코드 편집기 예시에서 show 매개변수가 false로 설정되어 있습니다. 이렇게 하면 레이어가 지도에 추가될 때 레이어의 공개 상태가 사용 중지됩니다. 코드 편집기 지도의 오른쪽 상단에 있는 레이어 관리자를 사용하여 언제든지 다시 사용 설정할 수 있습니다.

ndwi_sf
Landsat 8 NDWI, 미국 샌프란시스코 베이 지역 청록색은 낮은 값이고 파란색은 높은 값입니다.

기본 색상 팔레트 저장

분류 이미지에 색상 팔레트를 저장하여 적용하는 것을 기억할 필요가 없도록 하려면 각 분류 대역에 특별히 이름이 지정된 문자열 이미지 속성 두 개를 설정하면 됩니다.

예를 들어 이미지에 'water', 'forest', 'other' 클래스에 해당하는 세 가지 값 0, 1, 2가 있는 'landcover'라는 밴드가 있는 경우 다음 속성을 설정하여 기본 시각화에서 각 클래스에 지정된 색상을 표시할 수 있습니다(분석에 사용된 값은 영향을 받지 않음).

  • landcover_class_values="0,1,2"
  • landcover_class_palette="0000FF,00FF00,AABBCD"

저작물 메타데이터를 설정하는 방법은 애셋 페이지를 참고하세요.

마스크

image.updateMask()를 사용하여 마스크 이미지의 픽셀이 0이 아닌 위치에 따라 개별 픽셀의 불투명도를 설정할 수 있습니다. 마스크에서 0과 같은 픽셀은 계산에서 제외되고 불투명도는 표시를 위해 0으로 설정됩니다. 다음 예시에서는 NDWI 임곗값(임곗값에 대한 자세한 내용은 관계형 연산 섹션 참조)을 사용하여 이전에 만든 NDWI 레이어의 마스크를 업데이트합니다.

코드 편집기(JavaScript)

// Mask the non-watery parts of the image, where NDWI < 0.4.
var ndwiMasked = ndwi.updateMask(ndwi.gte(0.4));
Map.addLayer(ndwiMasked, ndwiViz, 'NDWI masked');

Python 설정

Python API 및 대화형 개발을 위한 geemap 사용에 대한 자세한 내용은 Python 환경 페이지를 참조하세요.

import ee
import geemap.core as geemap

Colab(Python)

# Mask the non-watery parts of the image, where NDWI < 0.4.
ndwi_masked = ndwi.updateMask(ndwi.gte(0.4))

# Define a map centered on San Francisco Bay.
map_ndwi_masked = geemap.Map(center=[37.5010, -122.1899], zoom=10)

# Add the image layer to the map and display it.
map_ndwi_masked.add_layer(ndwi_masked, ndwi_viz, 'NDWI masked')
display(map_ndwi_masked)

시각화 이미지

image.visualize() 메서드를 사용하여 이미지를 표시 또는 내보내기용 8비트 RGB 이미지로 변환합니다. 예를 들어 거짓 색상 합성 및 NDWI를 3밴드 디스플레이 이미지로 변환하려면 다음을 사용합니다.

코드 편집기(JavaScript)

// Create visualization layers.
var imageRGB = image.visualize({bands: ['B5', 'B4', 'B3'], max: 0.5});
var ndwiRGB = ndwiMasked.visualize({
  min: 0.5,
  max: 1,
  palette: ['00FFFF', '0000FF']
});

Python 설정

Python API 및 대화형 개발을 위한 geemap 사용에 대한 자세한 내용은 Python 환경 페이지를 참조하세요.

import ee
import geemap.core as geemap

Colab(Python)

image_rgb = image.visualize(bands=['B5', 'B4', 'B3'], max=0.5)
ndwi_rgb = ndwi_masked.visualize(min=0.5, max=1, palette=['00FFFF', '0000FF'])

모자이크

마스킹 및 imageCollection.mosaic()(모자이크 처리에 대한 자세한 내용은 모자이크 처리 섹션 참고)를 사용하여 다양한 지도 제작 효과를 얻을 수 있습니다. mosaic() 메서드는 입력 컬렉션의 순서에 따라 출력 이미지의 레이어를 렌더링합니다. 다음 예시에서는 mosaic()를 사용하여 마스크 처리된 NDWI와 거짓 색상 합성을 결합하고 새 시각화를 가져옵니다.

코드 편집기(JavaScript)

// Mosaic the visualization layers and display (or export).
var mosaic = ee.ImageCollection([imageRGB, ndwiRGB]).mosaic();
Map.addLayer(mosaic, {}, 'mosaic');

Python 설정

Python API 및 대화형 개발을 위한 geemap 사용에 대한 자세한 내용은 Python 환경 페이지를 참조하세요.

import ee
import geemap.core as geemap

Colab(Python)

# Mosaic the visualization layers and display (or export).
mosaic = ee.ImageCollection([image_rgb, ndwi_rgb]).mosaic()

# Define a map centered on San Francisco Bay.
map_mosaic = geemap.Map(center=[37.5010, -122.1899], zoom=10)

# Add the image layer to the map and display it.
map_mosaic.add_layer(mosaic, None, 'mosaic')
display(map_mosaic)

이 예시에서는 두 시각화 이미지의 목록이 ImageCollection 생성자에 제공됩니다. 목록의 순서에 따라 이미지가 지도에 렌더링되는 순서가 결정됩니다.

mosaic_sf
Landsat 8 위색 합성 및 NDWI의 모자이크입니다. 미국 샌프란시스코 베이 지역

클립

image.clip() 메서드는 지도 제작 효과를 얻는 데 유용합니다. 다음 예시에서는 이전에 만든 모자이크를 샌프란시스코시 주변의 임의의 버퍼 영역으로 클립합니다.

코드 편집기(JavaScript)

// Create a circle by drawing a 20000 meter buffer around a point.
var roi = ee.Geometry.Point([-122.4481, 37.7599]).buffer(20000);

// Display a clipped version of the mosaic.
Map.addLayer(mosaic.clip(roi), null, 'mosaic clipped');

Python 설정

Python API 및 대화형 개발을 위한 geemap 사용에 대한 자세한 내용은 Python 환경 페이지를 참조하세요.

import ee
import geemap.core as geemap

Colab(Python)

# Create a circle by drawing a 20000 meter buffer around a point.
roi = ee.Geometry.Point([-122.4481, 37.7599]).buffer(20000)
mosaic_clipped = mosaic.clip(roi)

# Define a map centered on San Francisco.
map_mosaic_clipped = geemap.Map(center=[37.7599, -122.4481], zoom=10)

# Add the image layer to the map and display it.
map_mosaic_clipped.add_layer(mosaic_clipped, None, 'mosaic clipped')
display(map_mosaic_clipped)

이전 예에서 좌표는 Geometry 생성자에 제공되고 버퍼 길이는 20,000미터로 지정됩니다. 기하학 페이지에서 기하학에 대해 자세히 알아보세요.

clipped_sf
위에 표시된 모자이크는 미국 캘리포니아주 샌프란시스코 주변의 버퍼로 잘라낸 것입니다.

범주형 지도 렌더링

팔레트는 토지 피복 지도와 같은 불연속 값 지도를 렌더링하는 데도 유용합니다. 클래스가 여러 개인 경우 팔레트를 사용하여 각 클래스에 다른 색상을 제공합니다. 이 컨텍스트에서는 image.remap() 메서드를 사용하여 임의의 라벨을 연속 정수로 변환하는 것이 유용할 수 있습니다. 다음 예시에서는 팔레트를 사용하여 토지 피복 카테고리를 렌더링합니다.

코드 편집기(JavaScript)

// Load 2012 MODIS land cover and select the IGBP classification.
var cover = ee.Image('MODIS/061/MCD12Q1/2012_01_01')
  .select('LC_Type1');

// Define a palette for the 17 distinct land cover classes.
var igbpPalette = [
  '152106', '225129', '369b47', '30eb5b', '387242', // forest
  '6a2325', 'c3aa69', 'b76031', 'd9903d', '91af40',  // shrub, grass
  '111149', // wetlands
  'cdb33b', // croplands
  'cc0013', // urban
  '33280d', // crop mosaic
  'd7cdcc', // snow and ice
  'f7e084', // barren
  'aec3d4'  // water
];

// Specify the min and max labels and the color palette matching the labels.
Map.setCenter(-99.229, 40.413, 5);
Map.addLayer(cover,
             {min: 1, max: 17, palette: igbpPalette},
             'IGBP classification');

Python 설정

Python API 및 대화형 개발을 위한 geemap 사용에 대한 자세한 내용은 Python 환경 페이지를 참조하세요.

import ee
import geemap.core as geemap

Colab(Python)

# Load 2012 MODIS land cover and select the IGBP classification.
cover = ee.Image('MODIS/061/MCD12Q1/2012_01_01').select('LC_Type1')

# Define a palette for the 17 distinct land cover classes.
igbp_palette = [
    '152106',
    '225129',
    '369b47',
    '30eb5b',
    '387242',  # forest
    '6a2325',
    'c3aa69',
    'b76031',
    'd9903d',
    '91af40',  # shrub, grass
    '111149',  # wetlands
    'cdb33b',  # croplands
    'cc0013',  # urban
    '33280d',  # crop mosaic
    'd7cdcc',  # snow and ice
    'f7e084',  # barren
    'aec3d4',  # water
]

# Define a map centered on the United States.
map_palette = geemap.Map(center=[40.413, -99.229], zoom=5)

# Add the image layer to the map and display it. Specify the min and max labels
# and the color palette matching the labels.
map_palette.add_layer(
    cover, {'min': 1, 'max': 17, 'palette': igbp_palette}, 'IGBP classes'
)
display(map_palette)
landcover_palettized
IGBP 분류를 사용한 MODIS 2012 토지 피복

스타일이 지정된 레이어 설명

스타일이 지정된 레이어 설명자(SLD)를 사용하여 표시할 이미지를 렌더링할 수 있습니다. image.sldStyle()에 이미지의 기호화 및 색상 지정에 관한 XML 설명, 특히 RasterSymbolizer 요소를 제공합니다. RasterSymbolizer 요소에 관해 자세히 알아보려면 여기를 참고하세요. 예를 들어 SLD를 사용하여 카테고리 지도 렌더링 섹션에 설명된 토지 피복 지도를 렌더링하려면 다음을 사용합니다.

코드 편집기(JavaScript)

var cover = ee.Image('MODIS/061/MCD12Q1/2012_01_01').select('LC_Type1');

// Define an SLD style of discrete intervals to apply to the image.
var sld_intervals =
'<RasterSymbolizer>' +
  '<ColorMap type="intervals" extended="false">' +
    '<ColorMapEntry color="#152106" quantity="1" label="Evergreen Needleleaf Forest"/>' +
    '<ColorMapEntry color="#225129" quantity="2" label="Evergreen Broadleaf Forest"/>' +
    '<ColorMapEntry color="#369b47" quantity="3" label="Deciduous Needleleaf Forest"/>' +
    '<ColorMapEntry color="#30eb5b" quantity="4" label="Deciduous Broadleaf Forest"/>' +
    '<ColorMapEntry color="#387242" quantity="5" label="Mixed Deciduous Forest"/>' +
    '<ColorMapEntry color="#6a2325" quantity="6" label="Closed Shrubland"/>' +
    '<ColorMapEntry color="#c3aa69" quantity="7" label="Open Shrubland"/>' +
    '<ColorMapEntry color="#b76031" quantity="8" label="Woody Savanna"/>' +
    '<ColorMapEntry color="#d9903d" quantity="9" label="Savanna"/>' +
    '<ColorMapEntry color="#91af40" quantity="10" label="Grassland"/>' +
    '<ColorMapEntry color="#111149" quantity="11" label="Permanent Wetland"/>' +
    '<ColorMapEntry color="#cdb33b" quantity="12" label="Cropland"/>' +
    '<ColorMapEntry color="#cc0013" quantity="13" label="Urban"/>' +
    '<ColorMapEntry color="#33280d" quantity="14" label="Crop, Natural Veg. Mosaic"/>' +
    '<ColorMapEntry color="#d7cdcc" quantity="15" label="Permanent Snow, Ice"/>' +
    '<ColorMapEntry color="#f7e084" quantity="16" label="Barren, Desert"/>' +
    '<ColorMapEntry color="#aec3d4" quantity="17" label="Water"/>' +
  '</ColorMap>' +
'</RasterSymbolizer>';
Map.addLayer(cover.sldStyle(sld_intervals), {}, 'IGBP classification styled');

Python 설정

Python API 및 대화형 개발을 위한 geemap 사용에 대한 자세한 내용은 Python 환경 페이지를 참조하세요.

import ee
import geemap.core as geemap

Colab(Python)

cover = ee.Image('MODIS/061/MCD12Q1/2012_01_01').select('LC_Type1')

# Define an SLD style of discrete intervals to apply to the image.
sld_intervals = """
<RasterSymbolizer>
  <ColorMap  type="intervals" extended="false" >
    <ColorMapEntry color="#152106" quantity="1" label="Evergreen Needleleaf Forest"/>
    <ColorMapEntry color="#225129" quantity="2" label="Evergreen Broadleaf Forest"/>
    <ColorMapEntry color="#369b47" quantity="3" label="Deciduous Needleleaf Forest"/>
    <ColorMapEntry color="#30eb5b" quantity="4" label="Deciduous Broadleaf Forest"/>
    <ColorMapEntry color="#387242" quantity="5" label="Mixed Deciduous Forest"/>
    <ColorMapEntry color="#6a2325" quantity="6" label="Closed Shrubland"/>
    <ColorMapEntry color="#c3aa69" quantity="7" label="Open Shrubland"/>
    <ColorMapEntry color="#b76031" quantity="8" label="Woody Savanna"/>
    <ColorMapEntry color="#d9903d" quantity="9" label="Savanna"/>
    <ColorMapEntry color="#91af40" quantity="10" label="Grassland"/>
    <ColorMapEntry color="#111149" quantity="11" label="Permanent Wetland"/>
    <ColorMapEntry color="#cdb33b" quantity="12" label="Cropland"/>
    <ColorMapEntry color="#cc0013" quantity="13" label="Urban"/>
    <ColorMapEntry color="#33280d" quantity="14" label="Crop, Natural Veg. Mosaic"/>
    <ColorMapEntry color="#d7cdcc" quantity="15" label="Permanent Snow, Ice"/>
    <ColorMapEntry color="#f7e084" quantity="16" label="Barren, Desert"/>
    <ColorMapEntry color="#aec3d4" quantity="17" label="Water"/>
  </ColorMap>
</RasterSymbolizer>"""

# Apply the SLD style to the image.
cover_sld = cover.sldStyle(sld_intervals)

# Define a map centered on the United States.
map_sld_categorical = geemap.Map(center=[40.413, -99.229], zoom=5)

# Add the image layer to the map and display it.
map_sld_categorical.add_layer(cover_sld, None, 'IGBP classes styled')
display(map_sld_categorical)

색상 램프를 사용하여 시각화 이미지를 만들려면 ColorMap의 유형을 '램프'로 설정합니다. 다음 예시에서는 DEM을 렌더링하기 위한 'interval' 및 'ramp' 유형을 비교합니다.

코드 편집기(JavaScript)

// Load SRTM Digital Elevation Model data.
var image = ee.Image('CGIAR/SRTM90_V4');

// Define an SLD style of discrete intervals to apply to the image. Use the
// opacity keyword to set pixels less than 0 as completely transparent. Pixels
// with values greater than or equal to the final entry quantity are set to
// fully transparent by default.
var sld_intervals =
  '<RasterSymbolizer>' +
    '<ColorMap type="intervals" extended="false" >' +
      '<ColorMapEntry color="#0000ff" quantity="0" label="0 ﹤ x" opacity="0" />' +
      '<ColorMapEntry color="#00ff00" quantity="100" label="0 ≤ x ﹤ 100" />' +
      '<ColorMapEntry color="#007f30" quantity="200" label="100 ≤ x ﹤ 200" />' +
      '<ColorMapEntry color="#30b855" quantity="300" label="200 ≤ x ﹤ 300" />' +
      '<ColorMapEntry color="#ff0000" quantity="400" label="300 ≤ x ﹤ 400" />' +
      '<ColorMapEntry color="#ffff00" quantity="900" label="400 ≤ x ﹤ 900" />' +
    '</ColorMap>' +
  '</RasterSymbolizer>';

// Define an sld style color ramp to apply to the image.
var sld_ramp =
  '<RasterSymbolizer>' +
    '<ColorMap type="ramp" extended="false" >' +
      '<ColorMapEntry color="#0000ff" quantity="0" label="0"/>' +
      '<ColorMapEntry color="#00ff00" quantity="100" label="100" />' +
      '<ColorMapEntry color="#007f30" quantity="200" label="200" />' +
      '<ColorMapEntry color="#30b855" quantity="300" label="300" />' +
      '<ColorMapEntry color="#ff0000" quantity="400" label="400" />' +
      '<ColorMapEntry color="#ffff00" quantity="500" label="500" />' +
    '</ColorMap>' +
  '</RasterSymbolizer>';

// Add the image to the map using both the color ramp and interval schemes.
Map.setCenter(-76.8054, 42.0289, 8);
Map.addLayer(image.sldStyle(sld_intervals), {}, 'SLD intervals');
Map.addLayer(image.sldStyle(sld_ramp), {}, 'SLD ramp');

Python 설정

Python API 및 대화형 개발을 위한 geemap 사용에 대한 자세한 내용은 Python 환경 페이지를 참조하세요.

import ee
import geemap.core as geemap

Colab(Python)

# Load SRTM Digital Elevation Model data.
image = ee.Image('CGIAR/SRTM90_V4')

# Define an SLD style of discrete intervals to apply to the image.
sld_intervals = """
    <RasterSymbolizer>
      <ColorMap type="intervals" extended="false" >
        <ColorMapEntry color="#0000ff" quantity="0" label="0"/>
        <ColorMapEntry color="#00ff00" quantity="100" label="1-100" />
        <ColorMapEntry color="#007f30" quantity="200" label="110-200" />
        <ColorMapEntry color="#30b855" quantity="300" label="210-300" />
        <ColorMapEntry color="#ff0000" quantity="400" label="310-400" />
        <ColorMapEntry color="#ffff00" quantity="1000" label="410-1000" />
      </ColorMap>
    </RasterSymbolizer>"""

# Define an sld style color ramp to apply to the image.
sld_ramp = """
    <RasterSymbolizer>
      <ColorMap type="ramp" extended="false" >
        <ColorMapEntry color="#0000ff" quantity="0" label="0"/>
        <ColorMapEntry color="#00ff00" quantity="100" label="100" />
        <ColorMapEntry color="#007f30" quantity="200" label="200" />
        <ColorMapEntry color="#30b855" quantity="300" label="300" />
        <ColorMapEntry color="#ff0000" quantity="400" label="400" />
        <ColorMapEntry color="#ffff00" quantity="500" label="500" />
      </ColorMap>
    </RasterSymbolizer>"""

# Define a map centered on the United States.
map_sld_interval = geemap.Map(center=[40.413, -99.229], zoom=5)

# Add the image layers to the map and display it.
map_sld_interval.add_layer(
    image.sldStyle(sld_intervals), None, 'SLD intervals'
)
map_sld_interval.add_layer(image.sldStyle(sld_ramp), None, 'SLD ramp')
display(map_sld_interval)

SLD는 픽셀 값을 확장하여 연속 데이터의 시각화를 개선하는 데도 유용합니다. 예를 들어 다음 코드는 임의의 선형 스트레치 결과를 최솟값-최댓값 '정규화' 및 '히스토그램' 균등화와 비교합니다.

코드 편집기(JavaScript)

// Load a Landsat 8 raw image.
var image = ee.Image('LANDSAT/LC08/C02/T1/LC08_044034_20140318');

// Define a RasterSymbolizer element with '_enhance_' for a placeholder.
var template_sld =
  '<RasterSymbolizer>' +
    '<ContrastEnhancement><_enhance_/></ContrastEnhancement>' +
    '<ChannelSelection>' +
      '<RedChannel>' +
        '<SourceChannelName>B5</SourceChannelName>' +
      '</RedChannel>' +
      '<GreenChannel>' +
        '<SourceChannelName>B4</SourceChannelName>' +
      '</GreenChannel>' +
      '<BlueChannel>' +
        '<SourceChannelName>B3</SourceChannelName>' +
      '</BlueChannel>' +
    '</ChannelSelection>' +
  '</RasterSymbolizer>';

// Get SLDs with different enhancements.
var equalize_sld = template_sld.replace('_enhance_', 'Histogram');
var normalize_sld = template_sld.replace('_enhance_', 'Normalize');

// Display the results.
Map.centerObject(image, 10);
Map.addLayer(image, {bands: ['B5', 'B4', 'B3'], min: 0, max: 15000}, 'Linear');
Map.addLayer(image.sldStyle(equalize_sld), {}, 'Equalized');
Map.addLayer(image.sldStyle(normalize_sld), {}, 'Normalized');

Python 설정

Python API 및 대화형 개발을 위한 geemap 사용에 대한 자세한 내용은 Python 환경 페이지를 참조하세요.

import ee
import geemap.core as geemap

Colab(Python)

# Load a Landsat 8 raw image.
image = ee.Image('LANDSAT/LC08/C02/T1/LC08_044034_20140318')

# Define a RasterSymbolizer element with '_enhance_' for a placeholder.
template_sld = """
<RasterSymbolizer>
  <ContrastEnhancement><_enhance_/></ContrastEnhancement>
  <ChannelSelection>
    <RedChannel>
      <SourceChannelName>B5</SourceChannelName>
    </RedChannel>
    <GreenChannel>
      <SourceChannelName>B4</SourceChannelName>
    </GreenChannel>
    <BlueChannel>
      <SourceChannelName>B3</SourceChannelName>
    </BlueChannel>
  </ChannelSelection>
</RasterSymbolizer>"""

# Get SLDs with different enhancements.
equalize_sld = template_sld.replace('_enhance_', 'Histogram')
normalize_sld = template_sld.replace('_enhance_', 'Normalize')

# Define a map centered on San Francisco Bay.
map_sld_continuous = geemap.Map(center=[37.5010, -122.1899], zoom=10)

# Add the image layers to the map and display it.
map_sld_continuous.add_layer(
    image, {'bands': ['B5', 'B4', 'B3'], 'min': 0, 'max': 15000}, 'Linear'
)
map_sld_continuous.add_layer(image.sldStyle(equalize_sld), None, 'Equalized')
map_sld_continuous.add_layer(
    image.sldStyle(normalize_sld), None, 'Normalized'
)
display(map_sld_continuous)

Earth Engine에서 SLD를 사용할 때 참고할 사항은 다음과 같습니다.

  • OGC SLD 1.0 및 OGC SE 1.1이 지원됩니다.
  • 전달된 XML 문서는 완전할 수도 있고 RasterSymbolizer 요소 및 그 하위 요소만 있을 수도 있습니다.
  • 밴드는 Earth Engine 이름 또는 색인('1', '2', …)으로 선택할 수 있습니다.
  • 부동 소수점 이미지에는 히스토그램 및 정규화 대비 스트레치 메커니즘이 지원되지 않습니다.
  • 불투명도는 0.0(투명)인 경우에만 고려됩니다. 0이 아닌 불투명도 값은 완전히 불투명한 것으로 처리됩니다.
  • OverlapBehavior 정의는 현재 무시됩니다.
  • ShadedRelief 메커니즘은 현재 지원되지 않습니다.
  • ImageOutline 메커니즘은 현재 지원되지 않습니다.
  • Geometry 요소는 무시됩니다.
  • 히스토그램 균등화 또는 정규화가 요청되면 출력 이미지에 histogram_bandname 메타데이터가 포함됩니다.

썸네일 이미지

ee.Image.getThumbURL() 메서드를 사용하여 ee.Image 객체의 PNG 또는 JPEG 썸네일 이미지를 생성합니다. getThumbURL() 호출로 끝나는 표현식의 결과를 출력하면 URL이 출력됩니다. URL을 방문하면 Earth Engine 서버가 요청된 썸네일을 즉시 생성하도록 설정됩니다. 처리가 완료되면 이미지가 브라우저에 표시됩니다. 이미지의 마우스 오른쪽 버튼 클릭 컨텍스트 메뉴에서 적절한 옵션을 선택하여 다운로드할 수 있습니다.

thumbnail_in_browser
브라우저에서 PNG 썸네일로 표시된 SRTM 디지털 고도 모델.

getThumbURL() 메서드에는 위의 시각화 매개변수 표에 설명된 매개변수가 포함됩니다. 또한 썸네일의 공간 범위, 크기, 표시 투영을 제어하는 선택적 dimensions, region, crs 인수를 사용합니다.

ee.Image.getThumbURL()의 추가 매개변수(형식에 관한 참고사항 포함)
매개변수 설명 유형
dimensions 픽셀 단위의 썸네일 크기입니다. 단일 정수를 제공하면 이미지의 더 큰 가로세로 크기를 정의하고 더 작은 크기를 비례적으로 조정합니다. 기본값은 더 큰 이미지 가로세로 크기의 경우 512픽셀입니다. 'WIDTHxHEIGHT' 형식의 단일 정수 또는 문자열입니다.
region 렌더링할 이미지의 지리 공간 리전입니다. 기본적으로 전체 이미지 또는 제공된 도형의 경계입니다. GeoJSON 또는 선형 링을 정의하는 3개 이상의 점 좌표로 구성된 2D 목록
crs 대상 투영(예: 'EPSG:3857')입니다. 기본값은 WGS84('EPSG:4326')입니다. 문자열
형식 썸네일 형식을 PNG 또는 JPEG로 정의합니다. 기본 PNG 형식은 RGBA로 구현되며, 여기서 알파 채널은 이미지의 mask()로 정의된 유효한 픽셀과 잘못된 픽셀을 나타냅니다. 잘못된 픽셀은 투명합니다. 선택사항인 JPEG 형식은 RGB로 구현되며, 잘못된 이미지 픽셀은 RGB 채널에서 0으로 채워집니다. I: 'png' 또는 'jpg'

단일 대역 이미지는 palette 인수가 제공되지 않는 한 기본적으로 그레이 스케일로 설정됩니다. bands 인수가 제공되지 않는 한 멀티밴드 이미지는 기본적으로 처음 세 밴드의 RGB 시각화로 설정됩니다. 두 개의 밴드만 제공되는 경우 첫 번째 밴드는 빨간색으로, 두 번째 밴드는 파란색으로 매핑되고 녹색 채널은 0으로 채워집니다.

다음은 getThumbURL() 매개변수 인수의 다양한 조합을 보여주는 일련의 예시입니다. 이 스크립트를 실행할 때 출력되는 URL을 클릭하여 썸네일을 확인합니다.

코드 편집기(JavaScript)

// Fetch a digital elevation model.
var image = ee.Image('CGIAR/SRTM90_V4');

// Request a default thumbnail of the DEM with defined linear stretch.
// Set masked pixels (ocean) to 1000 so they map as gray.
var thumbnail1 = image.unmask(1000).getThumbURL({
  'min': 0,
  'max': 3000,
  'dimensions': 500,
});
print('Default extent:', thumbnail1);

// Specify region by rectangle, define palette, set larger aspect dimension size.
var thumbnail2 = image.getThumbURL({
  'min': 0,
  'max': 3000,
  'palette': ['00A600','63C600','E6E600','E9BD3A','ECB176','EFC2B3','F2F2F2'],
  'dimensions': 500,
  'region': ee.Geometry.Rectangle([-84.6, -55.9, -32.9, 15.7]),
});
print('Rectangle region and palette:', thumbnail2);

// Specify region by a linear ring and set display CRS as Web Mercator.
var thumbnail3 = image.getThumbURL({
  'min': 0,
  'max': 3000,
  'palette': ['00A600','63C600','E6E600','E9BD3A','ECB176','EFC2B3','F2F2F2'],
  'region': ee.Geometry.LinearRing([[-84.6, 15.7], [-84.6, -55.9], [-32.9, -55.9]]),
  'dimensions': 500,
  'crs': 'EPSG:3857'
});
print('Linear ring region and specified crs', thumbnail3);

Python 설정

Python API 및 대화형 개발을 위한 geemap 사용에 대한 자세한 내용은 Python 환경 페이지를 참조하세요.

import ee
import geemap.core as geemap

Colab(Python)

# Fetch a digital elevation model.
image = ee.Image('CGIAR/SRTM90_V4')

# Request a default thumbnail of the DEM with defined linear stretch.
# Set masked pixels (ocean) to 1000 so they map as gray.
thumbnail_1 = image.unmask(1000).getThumbURL({
    'min': 0,
    'max': 3000,
    'dimensions': 500,
})
print('Default extent:', thumbnail_1)

# Specify region by rectangle, define palette, set larger aspect dimension size.
thumbnail_2 = image.getThumbURL({
    'min': 0,
    'max': 3000,
    'palette': [
        '00A600',
        '63C600',
        'E6E600',
        'E9BD3A',
        'ECB176',
        'EFC2B3',
        'F2F2F2',
    ],
    'dimensions': 500,
    'region': ee.Geometry.Rectangle([-84.6, -55.9, -32.9, 15.7]),
})
print('Rectangle region and palette:', thumbnail_2)

# Specify region by a linear ring and set display CRS as Web Mercator.
thumbnail_3 = image.getThumbURL({
    'min': 0,
    'max': 3000,
    'palette': [
        '00A600',
        '63C600',
        'E6E600',
        'E9BD3A',
        'ECB176',
        'EFC2B3',
        'F2F2F2',
    ],
    'region': ee.Geometry.LinearRing(
        [[-84.6, 15.7], [-84.6, -55.9], [-32.9, -55.9]]
    ),
    'dimensions': 500,
    'crs': 'EPSG:3857',
})
print('Linear ring region and specified crs:', thumbnail_3)