Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
1
Help us understand the problem. What is going on with this article?
@mski_iksm

Google Earth Engine覚書2 〜これってどうやるの?〜

More than 3 years have passed since last update.

大量ダウンロード

python APIで実現可能
Earth Engineをpythonで使うためのセットアップ方法:https://developers.google.com/earth-engine/python_install
画像の大量ダウンロード実現方法:https://groups.google.com/forum/?hl=ja#!searchin/google-earth-engine-developers/export$20no$20click/google-earth-engine-developers/-MMukxVsRJI/rTMTrdwtjCoJ

で、どうするの

getDownloadURL()を使用
PlayGroundでもできるけど,URLをテキストで出力してそのままダウンロードするにはPythonが楽.

download.py
url=L8_image.getDownloadURL({"name":'landsat8_n'+str(lat)+"e"+str(lon),"scale": 150,"region": polygon})
print(url)

ただし,URLがhttpsなので,通常のwgetではSSL認証が必要になってダメ.
だから以下のようなダウンロード用の関数を定義して,使用する.

download2.py
def downloadZip(url):
    u = urllib2.urlopen(url)

    meta = u.info()

    # A zip download
    file_name = (meta.getheaders("Content-disposition")[0]).replace('attachment; filename=', '')
    f = open(file_name, 'wb')
    print "Downloading: %s " % (file_name)
    #os.system('cls')
    file_size_dl = 0
    block_sz = 8192
    while True:
        buffer = u.read(block_sz)
        if not buffer:
            break

        file_size_dl += len(buffer)
        f.write(buffer)
        status = r"%10d  " % (file_size_dl)
        status = status + chr(8)*(len(status)+1)
        print status,

    f.close()
    return
1
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
1
Help us understand the problem. What is going on with this article?