자습서: Microsoft 플래네터리 컴퓨터 프로 API를 사용하여 데이터 수집 및 시각화

STAC(SpatioTemporal Asset Catalog) 컬렉션은 GeoCatalog 내에서 관련 공간 자산을 인덱싱하고 저장하는 데 사용됩니다. 이 엔드 투 엔드 자습서에서는 새 STAC 컬렉션을 만들고, Sentinel-2 이미지를 컬렉션에 수집하고, GeoCatalog의 API를 통해 해당 이미지를 쿼리합니다.

이 자습서에서는 다음을 수행합니다.

  • 행성 컴퓨터 프로 GeoCatalog 내에서 자신의 STAC 컬렉션을 만들 것입니다
  • 유럽 우주국에서 위성 이미지를 해당 컬렉션에 통합
  • Planetary Computer Pro의 웹 인터페이스에서 컬렉션의 이미지를 시각화할 수 있도록 컬렉션을 구성합니다.
  • Planetary Computer Pro의 STAC API를 사용하여 STAC 컬렉션 내에서 데이터 쿼리

이 자습서에서는 코드 조각을 통해 기능을 보여주고 설명하며, 대화형 Notebook 스타일 환경을 위해 이 자습서를 Jupyter Notebook으로 다운로드합니다.

팁 (조언)

이 자습서에서는 REST API 접근 방식을 보여 줍니다. 간소화된 클라이언트 환경을 위해 Planetary Computer Pro Python SDK(pip install azure-planetarycomputer)를 사용할 수도 있습니다. SDK 예제는 개별 빠른 시작 가이드를 참조하세요.

필수 조건

이 자습서를 실행하기 전에 Azure 구독에 배포된 Planetary Computer Pro GeoCatalog가 필요합니다. 또한 이 Notebook을 실행하고 필요한 패키지를 설치하는 환경이 필요합니다. Python 가상 환경에서 Azure Machine Learning Virtual Machine 또는 Visual Studio Code의 Notebook 통합을 통해 이 자습서를 실행하는 것이 좋습니다. 그러나 다음 요구 사항이 충족되면 Jupyter Notebook을 실행할 수 있는 모든 위치에서 이 Notebook을 실행해야 합니다.

  • Python 3.10 이상
  • Azure CLI가 설치되고 az login을 실행하여 Azure 계정에 로그인했습니다.
  • 자습서 옵션 섹션에 나열된 필수 요구 사항이 설치됩니다.

Azure Machine Learning 또는 VS Code에서 Jupyter Notebook 열기

Azure CLI를 사용하여 Azure에 로그인

다음 명령은 Azure CLI를 사용하여 Azure에 로그합니다. 명령을 실행하고 지침에 따라 로그인합니다.

!az login

자습서 옵션 선택

이 자습서를 실행하기 전에 기존 GeoCatalog 인스턴스에 대한 기여자 액세스 권한이 필요합니다. geocatalog_url 변수에 GeoCatalog 인스턴스의 URL을 입력합니다. 이 자습서에서는 현재 Microsoft의 행성 컴퓨터 데이터 카탈로그에 저장된 ESA(유럽 우주국)에서 제공하는 Sentinel-2 이미지 컬렉션을 만듭니다.

# URL for your given GeoCatalog
geocatalog_url = (
    "<GEOCATALOG_URL>"
)
geocatalog_url = geocatalog_url.rstrip("/")  # Remove trailing slash if present

api_version = "2026-04-15"

# User selections for demo

# Collection within the Planetary Computer
pc_collection = "sentinel-2-l2a"

# Bounding box for AOI
bbox_aoi = [-22.455626, 63.834083, -22.395201, 63.880750]

# Date range to search for imagery
param_date_range = "2024-02-04/2024-02-11"

# Maximum number of items to ingest
param_max_items = 6

필요한 패키지 가져오기

STAC 컬렉션을 만들려면 몇 가지 Python 패키지를 가져오고 필요한 액세스 토큰을 검색하는 도우미 함수를 정의해야 합니다.

pip install pystac-client azure-identity requests pillow
# Import the required packages
import json
import random
import string
import time
from datetime import datetime, timedelta, timezone
from io import BytesIO
from typing import Any, Optional, Dict

import requests
from azure.identity import AzureCliCredential
from IPython.display import Markdown as md
from IPython.display import clear_output
from PIL import Image
from pystac_client import Client

# Function to get a bearer token for the  Planetary Computer Pro API
MPC_APP_ID = "https://geocatalog.spatio.azure.com"

_access_token = None
def getBearerToken():
    global _access_token
    if not _access_token or datetime.fromtimestamp(_access_token.expires_on) < datetime.now() + timedelta(minutes=5):
        credential = AzureCliCredential()
        _access_token = credential.get_token(f"{MPC_APP_ID}/.default")

    return {"Authorization": f"Bearer {_access_token.token}"}

# Method to print error messages when checking response status
def raise_for_status(r: requests.Response) -> None:
    try:
        r.raise_for_status()
    except requests.exceptions.HTTPError as e:
        try:
            print(json.dumps(r.json(), indent=2))
        except:
            print(r.content)
        finally:
            raise

STAC 컬렉션 만들기

STAC 컬렉션 JSON 정의

다음으로 STAC 컬렉션을 JSON 항목으로 정의합니다. 이 자습서에서는 Microsoft의 Planetary Computer 내에서 Sentinel-2-l2a 컬렉션에 대한 기존 STAC 컬렉션 JSON을 사용합니다. 다른 기존 컬렉션과 충돌하지 않도록 컬렉션에 임의의 ID와 제목이 할당됩니다.

# Load example STAC collection JSON

response = requests.get(
    f"https://planetarycomputer.microsoft.com/api/stac/v1/collections/{pc_collection}"
)
raise_for_status(response)
stac_collection = response.json()

collection_id = pc_collection + "-tutorial-" + str(random.randint(0, 1000))

# Generate a unique name for the test collection
stac_collection["id"] = collection_id
stac_collection["title"] = collection_id

# Determine the storage account and container for the assets
pc_storage_account = stac_collection.pop("msft:storage_account")
pc_storage_container = stac_collection.pop("msft:container")
pc_collection_asset_container = (
    f"https://{pc_storage_account}.blob.core.windows.net/{pc_storage_container}"
)

# View your STAC collection JSON
stac_collection

GeoCatalog 내에서 컬렉션을 만들 때 컬렉션 JSON은 컬렉션과 연결된 컬렉션 수준 자산(예: 컬렉션 썸네일)을 가질 수 없으므로 먼저 기존 자산을 제거합니다(나중에 썸네일을 다시 추가할 필요가 없음).

# Save the thumbnail url
thumbnail_url = stac_collection['assets']['thumbnail']['href']

# Remove the assets field from the JSON (you'll see how to add this back later)
print("Removed the following items from the STAC Collection JSON:")
stac_collection.pop('assets')
# Create a STAC collection by posting to the STAC collections API

collections_endpoint = f"{geocatalog_url}/stac/collections"

response = requests.post(
    collections_endpoint,
    json=stac_collection,
    headers=getBearerToken(),
    params={"api-version": api_version}
)

if response.status_code==201:
    print("STAC Collection created named:",stac_collection['title'])
else:
    raise_for_status(response)

GeoCatalog 웹 인터페이스를 열면 "컬렉션" 탭 아래에 새 컬렉션이 나열됩니다.

컬렉션 썸네일 접근

다음으로 컬렉션에 썸네일을 추가하여 컬렉션과 함께 표시되도록 합니다. 이 데모에서는 Microsoft의 Planetary Computer 내에 있는 기존 Sentinel-2 컬렉션의 썸네일을 사용합니다.

# Read thumbnail for your collection

thumbnail_response = requests.get(thumbnail_url)
raise_for_status(thumbnail_response)
img = Image.open(BytesIO(thumbnail_response.content))
img

행성 컴퓨터 Pro GeoCatalog에 썸네일 추가

썸네일을 읽은 후 필요한 자산 json과 함께 GeoCatalogs의 컬렉션 자산 API 엔드포인트에 게시하여 컬렉션에 추가할 수 있습니다.

# Define the GeoCatalog collections API endpoint
collection_assets_endpoint = f"{geocatalog_url}/stac/collections/{collection_id}/assets"

# Read the example thumbnail from this collection from the Planetary Computer
thumbnail = {"file": ("lulc.png", thumbnail_response.content)}

# Define the STAC collection asset type - thumbnail in this case
asset = {
    "data": '{"key": "thumbnail", "href":"", "type": "image/png", '
    '"roles":  ["test_asset"], "title": "test_asset"}'
}

# Post the thumbnail to the GeoCatalog collections asset endpoint
response = requests.post(
    collection_assets_endpoint,
    data=asset,
    files=thumbnail,
    headers=getBearerToken(),
    params={"api-version": api_version}
)

if response.status_code==201:
    print("STAC Collection thumbnail updated for:",stac_collection['title'])
else:
    raise_for_status(response)

행성 컴퓨터 Pro GeoCatalog 내에서 새 컬렉션을 읽습니다.

브라우저를 새로 고치면 썸네일을 볼 수 있습니다. 컬렉션 엔드포인트에 대해 다음 호출을 수행하여 프로그래밍 방식으로 컬렉션 JSON을 검색할 수도 있습니다.

# Request the collection JSON from your GeoCatalog
collection_endpoint = f"{geocatalog_url}/stac/collections/{stac_collection['id']}"

response = requests.get(
    collection_endpoint,
    json={'collection_id':stac_collection['id']},
    headers=getBearerToken(),
    params={"api-version": api_version}
)

if response.status_code==200:
    print("STAC Collection successfully read:",stac_collection['title'])
else:
    raise_for_status(response)

response.json()
print(f"""
You successfully created a new STAC Collection in GeoCatalog named {collection_id}.
You can view your collection by visiting the GeoCatalog Explorer: {geocatalog_url}/collections
""")

STAC 항목 및 & 자산 수집

이 컬렉션을 만든 후에는 GeoCatalog의 Items API를 사용하여 STAC 컬렉션에 새 STAC 항목을 수집할 준비가 된 것입니다. 다음을 통해 이 프로세스를 수행합니다.

  1. Microsoft의 행성 컴퓨터에서 SAS 토큰 가져오기
  2. GeoCatalog 내에서 해당 토큰을 수집 원본으로 등록
  3. 해당 컬렉션의 STAC 항목을 GeoCatalog의 Item API에 게시
  4. 항목이 성공적으로 수집되었는지 확인합니다.
ingestion_sources_endpoint = f"{geocatalog_url}/inma/ingestion-sources"
ingestion_source_endpoint = lambda id: f"{geocatalog_url}/inma/ingestion-sources/{id}"


def find_ingestion_source(container_url: str) -> Optional[Dict[str, Any]]:

    response = requests.get(
        ingestion_sources_endpoint,
        headers=getBearerToken(),
        params={"api-version": api_version},
    )

    for source in response.json()["value"]:
        ingestion_source_id = source["id"]

        response = requests.get(
            ingestion_source_endpoint(ingestion_source_id),
            headers=getBearerToken(),
            params={"api-version": api_version},
        )
        raise_for_status(response)

        response = response.json()

        if response["connectionInfo"]["containerUrl"] == container_url:
            return response


def create_ingestion_source(container_url: str, sas_token: str):
    response = requests.post(
        ingestion_sources_endpoint,
        json={
            "kind": "SasToken",
            "connectionInfo": {
                "containerUrl": container_url,
                "sasToken": sas_token,
            },
        },
        headers=getBearerToken(),
        params={"api-version": api_version},
    )
    raise_for_status(response)


def remove_ingestion_source(ingestion_source_id: str):
    response = requests.delete(
        ingestion_source_endpoint(ingestion_source_id),
        headers=getBearerToken(),
        params={"api-version": api_version},
    )
    raise_for_status(response)

행성 컴퓨터 쿼리

먼저 행성 컴퓨터를 쿼리하여 특정 요구 사항과 일치하는 Sentinel-2 이미지를 검색해야 합니다. 이 경우 행성 컴퓨터에서 다음 조건과 일치하는 Sentinel-2 이미지를 찾고 있습니다.

  • 컬렉션 - Sentinel-2-l2a 컬렉션의 이미지
  • 시간 범위 - 2024년 2월 4일부터 2월 11일 사이에 수집됨
  • 관심 영역 - 남부 아이슬란드에 수집된 이미지 (경계 상자로 정의됨)

이 검색을 수행하면 행성 컴퓨터 내에서 일치하는 STAC 항목을 찾을 수 있습니다.

# Search criteria
print("Using the below parameters to search the Planetary Computer:\n")
print("Collection:", pc_collection)
print("Bounding box for area of interest:",bbox_aoi)
print("Date range:",param_date_range)
print("Max number of items:",param_max_items)
# Query the Planetary Computer

# Connect to the Planetary Computer
catalog = Client.open("https://planetarycomputer.microsoft.com/api/stac/v1")

search = catalog.search(collections=[pc_collection], bbox=bbox_aoi, datetime=param_date_range)
total_items = search.item_collection()

items = total_items[:param_max_items]
print("Total number of matching items:",len(total_items))
print("Total number of items for ingest base on user selected parameter:",len(items))

if total_items==0:
    print("No items matched your user specified parameters used at the top of this demo. Update these parameters")
# Print an example STAC item returned by the Planetary Computer
items[0]

수집 소스 등록

이러한 STAC 항목 및 관련 자산(이미지)을 GeoCatalog 컬렉션에 수집하려면 새 수집 원본을 등록해야 하는지 확인해야 합니다. 수집 원본은 GeoCatalog에서 액세스 권한이 있는 스토리지 위치(Azure Blob Storage 컨테이너)를 추적하는 데 사용됩니다.

수집 원본 등록은 GeoCatalog에 스토리지 컨테이너의 위치와 컨테이너에 액세스할 수 있는 읽기 권한이 있는 SAS 토큰을 제공하여 수행됩니다. STAC 항목 또는 관련 자산이 스토리지 컨테이너에 있는 경우 GeoCatalog가 해당 수집 항목에 접근할 수 있는 권한이 없으면 수집에 실패합니다.

이 프로세스를 시작하려면 먼저 Planetary Computer에서 Sentinel-2 이미지가 있는 컨테이너에 대한 읽기 권한을 부여하는 SAS 토큰을 요청합니다.

# Request API token from the Planetary Computer

pc_token = requests.get("https://planetarycomputer.microsoft.com/api/sas/v1/token/{}".format(pc_collection)).json()
print(f"Planetary Computer API Token will expire {pc_token['msft:expiry']}")

다음으로 이 Azure Blob Storage 컨테이너 및 연결된 SAS 토큰을 GeoCatalog를 사용하여 수집 원본으로 등록하려고 합니다. 이 스토리지 컨테이너에 대한 데이터 수집 소스가 이미 존재할 수 있습니다. 그렇다면 기존 인제션 소스의 ID를 찾습니다.

경고

발견된 중복 수집 소스가 다음 15분 안에 만료되는 토큰을 포함하는 경우, 삭제되고 대체됩니다. 현재 실행 중인 수집에서 사용 중인 수집 원본을 삭제 시 수집이 중단될 수 있습니다.

existing_ingestion_source: Optional[Dict[str, Any]] = find_ingestion_source(pc_collection_asset_container)

if existing_ingestion_source:
    connection_info = existing_ingestion_source["connectionInfo"]
    expiration = datetime.fromisoformat(connection_info["expiration"].split('.')[0]) # works in all Python 3.X versions
    expiration = expiration.replace(tzinfo=timezone.utc) # set timezone to UTC
    if expiration < datetime.now(tz=timezone.utc) + timedelta(minutes=15):
        print(f"Recreating existing ingestion source for {pc_collection_asset_container}")
        remove_ingestion_source(existing_ingestion_source["id"])
        create_ingestion_source(pc_collection_asset_container, pc_token["token"])
    else:
        print(f"Using existing ingestion source for {pc_collection_asset_container} with expiration {expiration}")
else:
    print(f"Creating ingestion source for {pc_collection_asset_container}")
    create_ingestion_source(pc_collection_asset_container, pc_token["token"])

GeoCatalog의 항목 API를 사용하여 STAC 항목 수집

이제 수집 원본을 등록했거나 원본이 있는지 확인했으므로 GeoCatalog의 항목 API를 사용하여 행성 컴퓨터 내에서 찾은 STAC 항목을 수집합니다. GeoCatalog 내에서 새 수집 작업을 만드는 항목 API에 각 항목을 게시하여 이 작업을 수행합니다.

# Ingest items

items_endpoint = f"{geocatalog_url}/stac/collections/{collection_id}/items"

operation_ids = []

for item in items:

    item_json = item.to_dict()
    item_json['collection'] = collection_id

    # Remove non-static assets
    del(item_json['assets']['rendered_preview'])
    del(item_json['assets']['preview'])
    del(item_json['assets']['tilejson'])

    response = requests.post(
        items_endpoint,
        json=item_json,
        headers=getBearerToken(),
        params={"api-version": api_version}
    )

    operation_ids.append(response.json()['id'])
    print(f"Ingesting item {item_json['id']} with operation id {response.json()['id']}")

Sentinel-2 항목 수집에 약간의 시간이 걸릴 수 있으므로 이 코드를 실행하여 GeoCatalog의 Operations API를 사용하여 수집 작업의 상태를 확인할 수 있습니다.

# Check the status of the operations
operations_endpoint = f"{geocatalog_url}/inma/operations"
# Loop through all the operations ids until the status of each operation ids is "Finished"
pending=True

start = time.time()

while pending:
    # Count the number of operation ids that are finished vs unfinished
    num_running = 0
    num_finished = 0
    num_failed = 0
    clear_output(wait=True)
    for operation_id in operation_ids:
        response = requests.get(
            f"{operations_endpoint}/{operation_id}",
            headers=getBearerToken(),
            params={"api-version": api_version},
        )
        raise_for_status(response)
        status = response.json()["status"]
        print(f"Operation id {operation_id} status: {status}")
        if status == "Running":
            num_running+=1
        elif status == "Failed":
            num_failed+=1
        elif status == "Succeeded":
            num_finished+=1
    
    num_running
    stop=time.time()
    # Print the summary of num finished, num running and num failed
    
    print("Ingesting Imagery:")
    print(f"\tFinished: {num_finished}\n\tRunning: {num_running}\n\tFailed: {num_failed}")
    print("Time Elapsed (seconds):",str(stop-start))
    
    if num_running == 0:
        pending=False
        print(f"Ingestion Complete!\n\t{num_finished} items ingested.\n\t{num_failed} items failed.")

    else:
        print(f"Waiting for {num_running} operations to finish")
        time.sleep(5)

웹 브라우저를 새로 고치고 항목 탭을 클릭하여 새로 업로드된 항목을 볼 수 있습니다.

컬렉션 관리

이러한 STAC 항목 및 관련 자산(이미지)을 STAC 컬렉션에 수집했으므로 GeoCatalog 웹 인터페이스에서 이러한 항목을 시각화하기 전에 GeoCatalog에 다른 구성 파일을 제공해야 합니다.

컬렉션 렌더링 구성

먼저 Planetary Computer에서 이 컬렉션에 대한 렌더링 구성 파일을 다운로드합니다. 이 구성 파일은 GeoCatalog에서 읽어 탐색기 내에서 다양한 방식으로 이미지를 렌더링할 수 있습니다. 이는 STAC 항목에 결합할 수 있는 다양한 자산(이미지)이 포함될 수 있기 때문에 표시되거나 보이지 않는 기능을 강조 표시하는 지정된 영역의 완전히 새로운 이미지를 만들 수 있기 때문입니다. 예를 들어 Sentinel-2 STAC 항목에는 전자기 스펙트럼의 여러 부분에서 12개 이상의 이미지가 있습니다. 이 렌더링 구성은 GeoCatalog에 이러한 이미지를 결합하여 자연색 또는 가색(색 적외선)으로 이미지를 표시할 수 있도록 하는 방법을 설명합니다.

# Read render JSON from Planetary Computer

render_json = requests.get("https://planetarycomputer.microsoft.com/api/data/v1/mosaic/info?collection={}".format(pc_collection)).json()
render_json['renderOptions']

Planetary Computer에서 이 렌더링 옵션 구성을 읽은 후 렌더링 옵션 엔드포인트에 이 구성을 게시하여 컬렉션에 대해 이러한 렌더링 옵션을 사용하도록 설정할 수 있습니다.

# Post render options config to GeoCatalog render-options API

render_config_endpoint = f"{geocatalog_url}/stac/collections/{collection_id}/configurations/render-options"

for render_option in render_json['renderOptions']:

    # Rename render configs such that they can be stored by GeoCatalog
    render_option['id'] = render_option['name'].translate(str.maketrans('', '', string.punctuation)).lower().replace(" ","-")[:30]

    # Post render definition
    response = requests.post(
        render_config_endpoint,
        json=render_option,
        headers=getBearerToken(),
        params={"api-version": api_version}
    )

모자이크 정의

위에서 설명한 렌더링 구성과 마찬가지로 GeoCatalog의 탐색기를 사용하면 컬렉션에 대해 하나 이상의 모자이크 정의를 지정할 수 있습니다. 이러한 모자이크 정의를 사용하면 Explorer 내에 표시되는 항목을 필터링하는 방법을 GeoCatalog 탐색기에 지시할 수 있습니다. 예를 들어 한 기본 렌더링 구성(다음 셀에 표시됨)은 GeoCatalog에 지정된 영역에 대한 최신 이미지를 표시하도록 지시합니다. 고급 렌더링 구성을 사용하면 2023년 10월에 캡처된 지정된 위치에 대해 가장 흐린 이미지와 같은 다양한 보기를 렌더링할 수 있습니다.

# Post mosaic definition

mosiacs_config_endpoint = f"{geocatalog_url}/stac/collections/{collection_id}/configurations/mosaics"

response = requests.post(
    mosiacs_config_endpoint,
    json={"id": "mos1",
          "name": "Most recent available",
          "description": "Most recent available imagery in this collection",
          "cql": []
    },
    headers=getBearerToken(),
    params={"api-version": api_version}
)

GeoCatalog 웹 인터페이스 열기

축하합니다! 컬렉션을 만들고, STAC 항목 및 자산을 추가하고, GeoCatalog 웹 인터페이스 내에서 탐색기를 통해 볼 수 있도록 필요한 구성 파일을 포함하도록 컬렉션을 업데이트했습니다.

웹 인터페이스에서 GeoCatalog 탐색기로 다시 이동하여 컬렉션을 봅니다.

STAC API를 통한 쿼리 컬렉션

이제 GeoCatalog 탐색기에서 컬렉션을 확인했으므로 GeoCatalog의 STAC API를 사용하여 추가 분석을 위해 STAC 항목 및 자산을 검색하고 검색하는 방법을 살펴보겠습니다.

이 프로세스는 GeoCatalog의 STAC API에 검색을 게시하여 시작합니다. 구체적으로 말해, Planetary Computer에서 이미지를 추출 시 사용한 원래 경계 상자에 속하는 이미지가 컬렉션에 있는지를 검색합니다.

당연히 이 쿼리는 이전에 컬렉션에 배치한 모든 STAC 항목을 반환합니다.

stac_search_endpoint = f"{geocatalog_url}/stac/search"

response = requests.post(
    stac_search_endpoint,
    json={"collections":[collection_id],
          "bbox":bbox_aoi
    },
    headers=getBearerToken(),
    params={"api-version": api_version, "sign": "true"}
)

matching_items = response.json()['features']
print(len(matching_items))

이전 쿼리에서 sign :true라는 다른 매개 변수도 제공했습니다. 그러면 GeoCatalog에서 Azure Blob Storage에서 지정된 자산을 읽을 수 있는 서명된 href(항목 href + SAS 토큰)를 반환하도록 지시합니다.

# Download one of the assets bands, band 09
asset_href = matching_items[0]['assets']['B09']['href']
print(asset_href)

response = requests.get(asset_href)
img = Image.open(BytesIO(response.content))
img

자원을 정리하세요

항목 삭제

이 시점에서 GeoCatalog 컬렉션을 만들고, 컬렉션에 항목 및 자산을 추가하고, GeoCatalog의 STAC API를 사용하여 해당 항목 및 자산을 검색했습니다. 이 자습서의 마지막 단계에서는 이러한 항목을 제거하고 컬렉션을 삭제합니다.

# Delete all items

for item in matching_items:
    response = requests.delete(
        f"{items_endpoint}/{item['id']}",
        headers=getBearerToken(),
        params={"api-version": api_version}
    )

다음 명령을 실행하여 모든 항목이 삭제되었는지 확인할 수 있습니다. 항목 및 관련 자산을 완전히 삭제하는 데 1~2분 정도 걸릴 수 있습니다.

# Confirm that all the items have been deleted
response = requests.post(
    stac_search_endpoint,
    json={"collections":[stac_collection['id']],
          "bbox": bbox_aoi
    },
    headers=getBearerToken(),
    params={"api-version": api_version, "sign": "true"}
)

matching_items = response.json()['features']
print(len(matching_items))

컬렉션 삭제

이제 마지막 단계로 GeoCatalog 인스턴스에서 컬렉션을 완전히 삭제할 수 있습니다.

# Delete the collection
response = requests.delete(
    f"{collections_endpoint}/{collection_id}",
    headers=getBearerToken(),
    params={"api-version": api_version}
)

raise_for_status(response)
print(f"STAC Collection deleted: {collection_id}")

다음 단계

이 엔드 투 엔드 자습서에서는 새 STAC 컬렉션을 만들고, Sentinel-2 이미지를 컬렉션에 수집하고, GeoCatalog의 API를 통해 해당 이미지를 쿼리하는 프로세스를 안내했습니다. 이러한 각 항목에 대해 자세히 알아보려면 다음 다른 자료를 살펴보세요.