LoginSignup
0
1

More than 3 years have passed since last update.

Google Earth EngineからPythonを使ってプロダクトをまとめてダウンロード(複数年)

Last updated at Posted at 2021-04-08

概要

 先日投稿した「Google Earth EngineからPythonを使ってプロダクトをまとめてダウンロード」の記事では単一年のデータをまとめてGEEからダウンロードする方法についてご紹介しましたが、対象年が複数年に渡る場合についても処理をループで回すことでGoogle Driveへのダウンロードが可能です。

データ

 今回ダウンロードしたのは、MODISプロダクトのうちで森林火災の強度を示す指標であるFRP (Fire Radiation Power)を格納したMOD14A1です。

コード

 基本の構成は「Google Earth EngineからPythonを使ってプロダクトをまとめてダウンロード」と同一ですが、ループを使ってフォルダに名前を付けながら2002年から2019年にかけて取得されたデータをGoogle driveへとダウンロードしています。ImageCollection単位でダウンロードを行っているため、個々の画像のダウンロード自体をループで処理する場合よりもループの回数が少なくなり、処理が速いのではないかなと思います(Pythonでループを入れ子すると処理時間がとても長くなる場合が多いので)。

GeeDownload.py
!pip install earthengine-api
!pip install unidecode
!pip install geetools

import ee

ee.Authenticate() #認証を求められる
ee.Initialize() 

band=['MaxFRP'] #バンドの選択
ROI =ee.Geometry.Polygon([98,58,117.995,58,117.995,50.004,98,50.004]) #関心領域の設定

from geetools import batch
from tqdm import tqdm

year=[f'{y}' for y in range(2002,2020)] #対象年のリスト

for y in tqdm(year):
  FireData=ee.ImageCollection("MODIS/006/MOD14A1").filterDate(f'{y}-07-01', f'{y}-09-01').filterBounds(ROI);
  tasks=batch.Export.imagecollection.toDrive(
      collection=FireData.select(band),
      folder=f'FRPdata_MOD14A1_{y}', #f-stringsを使ってフォルダ名を年毎に変更する
      scale= 500,
      region= ROI)
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1