이미지 내보내기

Earth Engine에서 GeoTIFF 또는 TFRecord 형식으로 이미지를 내보낼 수 있습니다. 출력 옵션에 관한 자세한 내용은 구성 매개변수를 참고하세요.

설정 예시

먼저 내보낼 이미지 데이터를 정의합니다.

코드 편집기 (JavaScript)

// Load a landsat image and select three bands.
var landsat = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_123032_20140515')
  .select(['B4', 'B3', 'B2']);

// Create a geometry representing an export region.
var geometry = ee.Geometry.Rectangle([116.2621, 39.8412, 116.4849, 40.01236]);

Python 설정

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

import ee
import geemap.core as geemap

Colab (Python)

# Load a landsat image and select three bands.
landsat = ee.Image('LANDSAT/LC08/C02/T1_TOA/LC08_123032_20140515').select(
    ['B4', 'B3', 'B2']
)

# Create a geometry representing an export region.
geometry = ee.Geometry.Rectangle([116.2621, 39.8412, 116.4849, 40.01236])

다음으로 다음 내보내기에 사용될 투영 매개변수를 정의합니다. crs 매개변수를 사용하여 좌표계를 지정하고 crsTransform 매개변수를 사용하여 픽셀 그리드를 정확하게 지정합니다. crsTransform 매개변수는 행렬 우선 순서 [xScale, xShearing, xTranslation, yShearing, yScale, yTranslation]의 아핀 변환 행렬의 매개변수 목록입니다. 이미지의 원점은 xTranslationyTranslation 값으로 정의되고 이미지의 픽셀 크기는 xScaleyScale 값으로 정의됩니다. 아핀 행렬의 예를 참고하세요.

코드 편집기 (JavaScript)

// Retrieve the projection information from a band of the original image.
// Call getInfo() on the projection to request a client-side object containing
// the crs and transform information needed for the client-side Export function.
var projection = landsat.select('B2').projection().getInfo();

Python 설정

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

import ee
import geemap.core as geemap

Colab (Python)

# Retrieve the projection information from a band of the original image.
# Call getInfo() on the projection to request a client-side object containing
# the crs and transform information needed for the client-side Export function.
projection = landsat.select('B2').projection().getInfo()

scale 설정

scale 매개변수를 지정하면 Earth Engine에서 crsTransform 매개변수를 자동으로 계산합니다. 하지만 이미지의 크기만 설정한다고 해서 투영의 원점을 지정하는 것은 아니며, 동일한 픽셀 크기의 다른 이미지를 기준으로 이미지가 이동할 수 있습니다.

잠재적 전환의 이유는 scale 매개변수가 crsTransformxScaleyScale 값을 채우는 데 사용되지만 xTranslationyTranslation 값은 해당 xScaleyScale 값으로 나눈 값의 나머지가 0이 되도록 계산되기 때문입니다. 이 매개변수는 투영의 원점이 픽셀의 모서리에 있는 픽셀 그리드를 지정합니다. 이 규칙은 투영의 원점에서 오프셋된 그리드를 사용하는 일부 데이터 제공업체에서 사용하는 변환 매개변수와 다릅니다. 예를 들어 USGS에서 제공하는 Landsat 이미지는 투영의 원점에서 1/2픽셀만큼 오프셋된 변환 매개변수 (30m 대역의 경우 15m 오프셋)를 사용하는 반면, ESA에서 제공하는 Sentinel-2 이미지는 투영의 원점에 정렬된 변환 매개변수를 사용합니다. 내보내기에 지정된 crsTransform가 원본 이미지의 crsTransform와 일치하지 않으면 출력 픽셀이 기본적으로 최근접 이웃을 사용하여 리샘플링되므로 결과 이미지가 원본 이미지를 기준으로 이동합니다.

요약하자면 내보낸 이미지의 픽셀을 특정 이미지에 일치시켜야 하는 경우 그리드를 완전히 제어하려면 crscrsTransform 매개변수를 사용해야 합니다.

Drive로

Drive 계정으로 이미지를 내보내려면 Export.image.toDrive()를 사용하세요. 예를 들어 Landsat 이미지의 일부를 내보내려면 내보낼 영역을 정의한 다음 Export.image.toDrive()를 호출합니다.

코드 편집기 (JavaScript)

// Export the image, specifying the CRS, transform, and region.
Export.image.toDrive({
  image: landsat,
  description: 'imageToDriveExample_transform',
  crs: projection.crs,
  crsTransform: projection.transform,
  region: geometry
});

Python 설정

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

import ee
import geemap.core as geemap

Colab (Python)

# Export the image, specifying the CRS, transform, and region.
task = ee.batch.Export.image.toDrive(
    image=landsat,
    description='imageToDriveExample_transform',
    crs=projection['crs'],
    crsTransform=projection['transform'],
    region=geometry,
)
task.start()

이 코드가 실행되면 Code 편집기 Tasks 탭에 내보내기 작업이 생성됩니다. 태스크 옆에 있는 실행 버튼을 클릭하여 태스크를 시작합니다. 코드 편집기 섹션에서 작업 관리자에 대해 자세히 알아보세요. 이미지가 지정된 fileFormat로 Drive 계정에 생성됩니다.

Cloud Storage로

이미지를 Google Cloud Storage 버킷으로 내보내려면 Export.image.toCloudStorage()를 사용합니다. 이전 예의 Landsat 이미지를 Drive 대신 Cloud Storage로 내보내려면 다음을 사용하세요.

코드 편집기 (JavaScript)

// Export the image to Cloud Storage.
Export.image.toCloudStorage({
  image: landsat,
  description: 'imageToCloudExample',
  bucket: 'your-bucket-name',
  fileNamePrefix: 'exampleExport',
  crs: projection.crs,
  crsTransform: projection.transform,
  region: geometry
});

Python 설정

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

import ee
import geemap.core as geemap

Colab (Python)

# Export the image to Cloud Storage.
task = ee.batch.Export.image.toCloudStorage(
    image=landsat,
    description='imageToCloudExample',
    bucket='your-bucket-name',
    fileNamePrefix='exampleExport',
    crs=projection['crs'],
    crsTransform=projection['transform'],
    region=geometry,
)
task.start()

Drive로 내보내는 경우와 마찬가지로 Tasks 탭에서 내보내기를 시작합니다. Cloud Storage 버킷 위치는 성능 및 스토리지 비용에 영향을 줄 수 있습니다. 자세한 내용은 위치 고려사항에 관한 FAQ 항목을 참고하세요.

애셋

Earth Engine 애셋 폴더의 애셋으로 이미지를 내보내려면 Export.image.toAsset()를 사용하세요. Earth Engine 애셋을 관리하거나 사용 중인 스토리지 할당량을 확인하려면 애셋 관리자를 사용하세요. 다음 예는 동일한 밴드에 대해 서로 다른 피라미딩 정책을 사용하여 Landsat 이미지의 일부를 내보내는 방법을 보여줍니다. 피라미드화 정책은 Earth Engine에서 애셋의 낮은 해상도 버전을 계산하는 방법을 나타냅니다. 스케일 문서에서 Earth Engine이 여러 해상도를 처리하는 방법을 자세히 알아보세요.

코드 편집기 (JavaScript)

// Get band 4 from the Landsat image, copy it.
var band4 = landsat.select('B4').rename('b4_mean')
  .addBands(landsat.select('B4').rename('b4_sample'))
  .addBands(landsat.select('B4').rename('b4_max'));

// Export the image to an Earth Engine asset.
Export.image.toAsset({
  image: band4,
  description: 'imageToAssetExample',
  assetId: 'exampleExport',
  crs: projection.crs,
  crsTransform: projection.transform,
  region: geometry,
  pyramidingPolicy: {
    'b4_mean': 'mean',
    'b4_sample': 'sample',
    'b4_max': 'max'
  }
});

Python 설정

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

import ee
import geemap.core as geemap

Colab (Python)

# Get band 4 from the Landsat image, copy it.
band_4 = (
    landsat.select('B4')
    .rename('b4_mean')
    .addBands(landsat.select('B4').rename('b4_sample'))
    .addBands(landsat.select('B4').rename('b4_max'))
)

# Export the image to an Earth Engine asset.
task = ee.batch.Export.image.toAsset(
    image=band_4,
    description='imageToAssetExample',
    assetId='projects/your-project/assets/exampleExport',
    crs=projection['crs'],
    crsTransform=projection['transform'],
    region=geometry,
    pyramidingPolicy={
        'b4_mean': 'mean',
        'b4_sample': 'sample',
        'b4_max': 'max',
    },
)
task.start()

'.default' 키를 사용하여 명시적으로 지정되지 않은 모든 대역에 기본 피라미드화 정책을 제공할 수 있습니다. '.default' 키만 전달할 수도 있습니다. 예를 들어 모든 밴드를 기본적으로 '샘플' 피라미드화 정책으로 설정하려면 {'.default': 'sample'}를 사용합니다.

구성 매개변수

Export.image에 전달된 구성 매개변수 사전에는 scale (미터) 및 내보내기 영역이 ee.Geometry로 포함되어 있습니다. 내보낸 이미지는 지정된 크기의 픽셀로 지정된 영역을 덮습니다. 명시적으로 지정하지 않으면 출력의 CRS는 내보낼 이미지의 첫 번째 밴드에서 가져옵니다.

내보낸 이미지의 dimensions, crs 또는 crsTransform를 지정할 수도 있습니다. crscrsTransform에 관한 자세한 내용은 용어집을 참고하세요. 예를 들어 다른 데이터 소스에 정확하게 정렬된 픽셀 블록을 가져오려면 dimensions, crs, crsTransform를 지정합니다. 영역을 덮는 사전 정의된 크기의 픽셀 블록 (예: 256x256 썸네일 이미지)을 가져오려면 dimensionsregion을 지정합니다.

fileFormat 매개변수 (기본값: 'GeoTIFF')를 사용하여 이미지 출력 형식을 지정할 수 있습니다 (대상이 toAsset()가 아닌 경우).

formatOptions 매개변수

다른 구성 옵션은 formatOptions 매개변수로 설정되며, 이는 아래에 설명된 대로 각 fileFormat에 맞는 다른 형식 옵션으로 키가 지정된 사전이어야 합니다.

GeoTIFF

클라우드 최적화 GeoTIFF

클라우드 최적화 GeoTIFF를 내보내려면 cloudOptimized 키가 true로 설정된 formatOptions의 JavaScript 리터럴을 전달합니다. 이전 예시를 계속 진행합니다.

코드 편집기 (JavaScript)

// Export a cloud-optimized GeoTIFF.
Export.image.toDrive({
  image: landsat,
  description: 'imageToCOGeoTiffExample',
  crs: projection.crs,
  crsTransform: projection.transform,
  region: geometry,
  fileFormat: 'GeoTIFF',
  formatOptions: {
    cloudOptimized: true
  }
});

Python 설정

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

import ee
import geemap.core as geemap

Colab (Python)

# Export a cloud-optimized GeoTIFF.
task = ee.batch.Export.image.toDrive(
    image=landsat,
    description='imageToCOGeoTiffExample',
    crs=projection['crs'],
    crsTransform=projection['transform'],
    region=geometry,
    fileFormat='GeoTIFF',
    formatOptions={'cloudOptimized': True},
)
task.start()

클라우드 최적화 GeoTIFF는 Cloud Storage에서 Image로 다시 로드할 수 있습니다. 자세한 내용은 Image 개요 문서를 참고하세요.

Nodata

formatOptions 매개변수 내에서 noData 키를 사용하여 GeoTIFF nodata 값을 지정합니다. 예를 들면 다음과 같습니다.

코드 편집기 (JavaScript)

// Set a nodata value and replace masked pixels around the image edge with it.
var noDataVal = -9999;
landsat = landsat.unmask(noDataVal);

Export.image.toDrive({
  image: landsat,
  description: 'imageNoDataExample',
  crs: projection.crs,
  scale: 2000,  // large scale for minimal demo
  region: landsat.geometry(),  // full image bounds
  fileFormat: 'GeoTIFF',
  formatOptions: {
    noData: noDataVal,
  }
});

Python 설정

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

import ee
import geemap.core as geemap

Colab (Python)

# Set a nodata value and replace masked pixels around the image edge with it.
no_data_val = -9999
landsat = landsat.unmask(no_data_val)

task = ee.batch.Export.image.toDrive(
    image=landsat,
    description='imageNoDataExample',
    crs=projection['crs'],
    scale=2000,  # large scale for minimal demo
    region=landsat.geometry(),  # full image bounds
    fileFormat='GeoTIFF',
    formatOptions={'noData': no_data_val},
)
task.start()

nodata 값은 이미지의 PixelType에 유효한 범위 내에 있어야 합니다. 이미지 메타데이터를 출력하고 첫 번째 밴드의 data_type 속성을 확인하여 PixelType를 확인할 수 있습니다. 예를 들어 이미지 메서드 toShort() 또는 toInt()를 사용하여 데이터를 특정 유형으로 전송하여 이미지의PixelType를 설정할 수도 있습니다.

TFRecord

TFRecord 데이터 형식 페이지를 참고하세요.

maxPixels

maxPixels 매개변수는 매우 큰 내보내기가 실수로 생성되는 것을 방지하기 위한 것입니다. 기본값이 원하는 출력 이미지에 비해 너무 낮은 경우 maxPixels를 늘릴 수 있습니다. 예를 들면 다음과 같습니다.

Export.image.toDrive({
  image: landsat,
  description: 'maxPixelsExample',
  crs: projection.crs,
  crsTransform: projection.transform,
  region: geometry,
  maxPixels: 1e9
});

대용량 파일 내보내기

출력 이미지가 크면 여러 파일로 내보내집니다. GeoTIFF로 내보내는 경우 이미지가 타일로 분할됩니다. 각 카드의 파일 이름은 baseFilename-yMin-xMin 형식입니다. 여기서 xMinyMin는 내보낸 이미지의 전체 경계 상자 내 각 카드의 좌표입니다.

TFRecord로 내보내는 경우 N+1 파일의 경우 -00000, -00001,... -0000N가 파일에 추가됩니다. 이 순서를 유지하는 것은 파일에서 추론을 실행하고 예측을 이미지로 Earth Engine에 다시 업로드하려는 경우 중요합니다. 자세한 내용은 이미지를 TFRecord 파일로 업로드를 참고하세요.

코드 편집기에 표시되는 대로 이미지 내보내기

Earth Engine에서 화면에 렌더링된 이미지로 이미지를 내보내려면 시각화 이미지합성 및 모자이크 처리 섹션에 설명된 대로 시각화 이미지를 만듭니다. Code Editor는 'EPSG:3857' CRS를 사용하므로 내보내기에서 CRS를 'EPSG:3857'로 지정하여 Code Editor 지도에 표시된 것과 동일한 투영으로 이미지를 가져옵니다. 출력의 해상도 및 좌표계를 지정하는 방법에 관한 자세한 내용은 이미지 내보내기 구성 섹션을 참고하세요.