Google Earth Engine (GEE) como domínio público para grandes geodados

No último artigo, Google Earth Engine (GEE) como supercomputador público, tratou -se de trabalhar no editor de nuvem GEE, onde você só precisa ter o e-mail do Google para acessar. Se as necessidades são limitadas a tarefas únicas e gigabytes de dados recuperáveis, isso é o suficiente. Mas para a automação de muitas tarefas, mesmo pequenas, um editor de nuvem não é a melhor maneira de trabalhar, ainda mais quando você precisa receber rasters repetidamente com um tamanho total de terabytes. Nesses casos, outras ferramentas serão necessárias e hoje veremos as possibilidades de acesso a partir do shell do console e scripts Python e notebook Python Jupyter.









Na captura de tela de um laptop Python Jupyter, onde um raster com dados de densidade populacional para 2020 do Catálogo de dados do Earth Engine: WorldPop Global Project Population Data é exibido em um OpenStreetMap







Introdução



, . , 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 .







Gostaria de receber feedback dos leitores: vale a pena abordar tópicos mais complexos ou isso já está além do escopo do que interessa ao público de língua russa? Sei que muitos leitores aqui usam o Google Transtale e tradutores semelhantes, talvez você deva escrever imediatamente em inglês no LinkedIn, como já faço com publicações sobre geofísica.







Links



EEDAI - Imagem da API de dados do Google Earth Engine







Tutorial da API Raster







Camadas vetoriais







Usando GDAL / OGR para processamento e análise de dados







Camadas Raster







Manipulação de conjunto de dados raster (em grade)







DE GEE A NUMPY A GEOTIFF







Como carregar arquivos GeoJSON no BigQuery GIS








All Articles