REMOTE SENSING

지리공간 딥러닝용 지표수(Earth Surface Water) 데이터셋 소개

유병혁 2022. 12. 31. 21:12

안녕하세요? 이번 글은 지리공간 딥러닝용 지표수(Earth Surface Water) 데이터셋을 간략 소개해 보겠습니다. 이 글은 지리공간/금융 데이터 사이언티스트 Maurício Cordeiro(마우리시오 코르데이로) 님이 작성하신 'PyTorch의 TorchGeo를 이용한 지리공간 분석용 인공지능(1부)' 내용 일부를 발췌, 보완한 것입니다.

 

Artificial Intelligence for Geospatial Analysis with Pytorch’s TorchGeo (Part 1)

An end-to-end deep learning geospatial segmentation project using Pytorch and TorchGeo packages

towardsdatascience.com

지표수(Earth Surface Water) 데이터셋

지표수 데이터셋(CC BY 4.0 라이선스)은 세계 여러 지역의 이미지 패치와 해당 워터 마스크가 있습니다. 데이터셋은 공간해상도가 10m인 Sentinel-2 위성의 광학 영상(optical imagery)을 사용합니다.

 

Earth Surface Water Dataset

We provided a new dataset for deep learning of surface water features on Sentinel-2 satellite images. This dataset contains 95 scenes that are globally distributed. The related source code can be found at: https://github.com/xinluo2018/WatNet.  And the

zenodo.org

이 데이터셋의 또다른 장점은 결과를 비교할 수 있는 성능 벤치마크가 있다는 것입니다. 데이터셋과 관련해서는 아래 논문을 참고하시면 됩니다.

Luo, X., Tong, X., & Hu, Z. (2021). An applicable and automatic method for earth surface water mapping based on multispectral images. International Journal of Applied Earth Observation and Geoinformation, 103, 102472.

 

An applicable and automatic method for earth surface water mapping based on multispectral images

Earth’s surface water plays an important role in the global water cycle, environmental processes, and human society, and it is necessary to dynamicall…

www.sciencedirect.com

자, 그럼 지표수 데이터셋을 다운로드 받아볼까요?! 여기서는 주피터 노트북을 사용하겠습니다. wget 명령어를 사용하여 데이터셋을 직접 다운로드하고 압축을 해제해 보겠습니다.

 

GNU Wget for Windows

GNU Wget(그누 더블유겟)은 HTTP, HTTPS, FTP 및 FTPS를 사용하여 파일을 검색하기 위한 자유 소프트웨어 패키지(명령어 유틸리티)입니다. GNU Wget의 Windows 바이너리는 다음 링크를 이용하시면 됩니다.

 

GNU Wget 1.21.3 for Windows

 

eternallybored.org

링크 화면에서 64-bit EXE 'wget.exe' 파일을 다운로드 받고 'C:\Windows\System32' 폴더에 복사합니다.

이제 wget을 통해 지표수 데이터셋을 다운로드(dset-s2.zip) 받을 수 있습니다. 참고로 파일 크기는 583MB입니다.

!wget https://zenodo.org/record/5205674/files/dset-s2.zip

dset-s2.zip 파일을 압축 해제합니다.

import shutil
shutil.unpack_archive("dset-s2.zip")

데이터셋은 다음과 같은 구조를 가지고 있습니다. tra는 훈련셋(training set)을 나타내고 val은 검증셋(validation set)을 나타냅니다. 접미사 scene과 truth는 이미지 패치와 해당 마스크(ground truth)를 구분하기 위한 것입니다.

샘플을 열기 위해 훈련 이미지(tra_scene)와 훈련 마스크(tra_truth)를 리스트에 로드합니다.

from pathlib import  Path
import xarray as xr
import matplotlib.pyplot as plt

root = Path('dset-s2')
assert root.exists()

train_imgs = list((root/'tra_scene').glob('*.tif'))
train_masks = list((root/'tra_truth').glob('*.tif'))

# 이미지와 해당 마스크가 이름별로 일치하므로, 두 목록을 정렬하여 동기화 상태 유지
train_imgs.sort(); train_masks.sort()

XArray를 사용하여 하나의 인덱스를 엽니다.

idx = 0
img = xr.open_rasterio(train_imgs[idx])
mask = xr.open_rasterio(train_masks[idx])

 

다음으로 matplotlib으로 결과를 표시합니다.

_, axs = plt.subplots(1, 2, figsize=(15, 6))

# 이미지 플롯(plot the tile)
rgb = img.data[[2, 1, 0]].transpose((1, 2, 0))/3000
axs[0].imshow(rgb.clip(min=0, max=1))

# 마스크 플롯(plot the mask)
axs[1].imshow(mask.data.squeeze(), cmap='Blues')