大規模な地理データのパブリックドメインとしてのGoogleEarth Engine(GEE)

前回の記事、パブリックスーパーコンピューターとしてのGoogle Earthエンジン(GEE)は、アクセスするためにGoogleメールがあれば十分なクラウドエディターGEEでの作業に関するものでした。ニーズが1回限りのタスクとギガバイトの回復可能なデータに限定されている場合は、これで十分です。しかし、多くの小さなタスクを自動化する場合、クラウドエディターは最適な作業方法ではなく、合計サイズがテラバイトのラスターを繰り返し受信する必要がある場合はさらにそうです。このような場合、他のツールが必要になります。今日は、コンソールシェルとPythonスクリプトおよびPythonJupyterノートブックからのアクセスの可能性について見ていきます。









Python Jupyterラップトップのスクリーンショットでは、Earth Engineデータカタログからの2020年の人口密度データを含むラスター:WorldPopグローバルプロジェクト人口データがOpenStreetMapに表示されています







前書き



, . , Google Earth Engine (GEE), , . , . , GEE , . , , , (, ). , (ML) , ! , — GEE, Compute Engine . , , .







Google



Google Cloud SDK google-cloud-sdk. ( ) . :







$ gcloud auth list
Credentialed accounts:
 - youremail@gmail.com (active)
To set the active account, run
 $ gcloud config set account <account>
      
      





:







$ gcloud config set account <account>
      
      





:







$ gcloud auth login
      
      







buckets Google Drive, GEE GEE. , API .







C GEE buckets Export.table.toCloudStorage Export.image.toCloudStorage , Google Compute Engine. gsutil, :







$ gsutil du -h gs://gcp-pdp-osm-dev-earth-engine
      
      





(. -h). gsutil , (cp, rm,...), .







GEE Google Drive Export.table.toDrive Export.image.toDrive, - . Google Drive .







GEE API



Google Earth Engine (GEE) my-service-account@...iam.gserviceaccount.com: Create and register a service account to use Earth Engine. GEE KEYS JSON , Register a new service account. Python :







import ee
service_account = 'my-service-account@...iam.gserviceaccount.com'
credentials = ee.ServiceAccountCredentials(service_account, 'privatekey.json')
ee.Initialize(credentials)
      
      





Python API ee.Authenticate() .







$ earthengine earthengine --ee_config
      
      





, Python GDAL:







import os
from osgeo import gdal

os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "my-service-account.json"
      
      





GDAL:







export GOOGLE_APPLICATION_CREDENTIALS=my-service-account.json
      
      





GEE



API Method: projects.assets.getPixels , 32MB. , GDAL API, .







GDAL Python. WorldPop/GP/100m/pop 2020 . , :







export GOOGLE_APPLICATION_CREDENTIALS=my-service-account.json

# fetch collection
ogrinfo -ro -al "EEDA:" -oo COLLECTION=projects/earthengine-public/assets/WorldPop/GP/100m/pop -where "year=2020" 
# show one raster info
gdalinfo "EEDAI:projects/earthengine-public/assets/WorldPop/GP/100m/pop/ZWE_2020"
# fetch one raster to local drive
gdal_translate "EEDAI:projects/earthengine-public/assets/WorldPop/GP/100m/pop/ZWE_2020" ZWE_2020.tif
      
      





Python:







import os
from osgeo import ogr, gdal

# define service account key
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "my-service-account.json"
# fetch collection
driver = ogr.GetDriverByName('EEDA')
ds = driver.Open('EEDA:projects/earthengine-public/assets/WorldPop/GP/100m/pop')
layer = ds.GetLayer()
# filter collection by attribute
layer.SetAttributeFilter('year=2020')
# select 1st raster
for feature in layer:
    name = feature.GetField("name")
    crs = feature.GetField("band_crs")
    print ('raster name and crs:',name, crs)
    break
# fetch 1st raster from the collection to array
ds = gdal.Open(f'EEDAI:{name}')
band = ds.GetRasterBand(1)
array = band.ReadAsArray()
print ('raster shape:', array.shape)
      
      







«» Google Earth Engine. GEE , Python Jupyter , . , «» — GEE. , GDAL .







私は読者からのフィードバックを得ることに興味があります:より複雑なトピックに取り組む価値がありますか、それともこれはすでにロシア語を話す聴衆が興味を持っている範囲を超えていますか?ここの多くの読者がGoogleTranstaleや同様の翻訳者を使用していることを知っています。おそらく、地球物理学に関する出版物ですでに行っているように、LinkedInですぐに英語で書く必要があります。







リンク



EEDAI-Google Earth Engine DataAPIイメージ







ラスターAPIチュートリアル







ベクターレイヤー







データ処理と分析のためのGDAL / OGRの使用







ラスターレイヤー







ラスター(グリッド)データセットの処理







GEEからNUMPY、GEOTIFFへ







GeoJSONファイルをBigQueryGISにロードする方法








All Articles