Google Earth Engine (GEE) como dominio público para grandes geodatos

En el último artículo, Google Earth Engine (GEE) como supercomputadora pública, se trataba de trabajar en el editor en la nube GEE, donde solo necesitas tener el correo de Google para acceder. Si las necesidades se limitan a tareas únicas y gigabytes de datos recuperables, entonces esto es suficiente. Pero para la automatización de muchas tareas, incluso pequeñas, un editor en la nube no es la mejor manera de trabajar, y más aún cuando necesita recibir rásteres repetidamente con un tamaño total de terabytes. En tales casos, se requerirán otras herramientas y hoy veremos las posibilidades de acceso desde el shell de la consola y los scripts de Python y el cuaderno de Python Jupyter.









En la captura de pantalla de una computadora portátil Python Jupyter, donde se muestra un ráster con datos de densidad de población para 2020 del catálogo de datos de Earth Engine: WorldPop Global Project Population Data en un OpenStreetMap







Introducción



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







Me interesaría recibir comentarios de los lectores: ¿vale la pena abordar temas más complejos o esto ya está fuera del alcance de lo que interesa a la audiencia de habla rusa? Sé que muchos lectores aquí usan Google Transtale y traductores similares, tal vez debería escribir inmediatamente en inglés en LinkedIn, como ya lo hago con las publicaciones sobre geofísica.







Enlaces



EEDAI: imagen de la API de datos de Google Earth Engine







Tutorial de API ráster







Capas vectoriales







Uso de GDAL / OGR para procesamiento y análisis de datos







Capas ráster







Manejo de conjuntos de datos ráster (en cuadrícula)







DE GEE A NUMPY A GEOTIFF







Cómo cargar archivos GeoJSON en BigQuery GIS








All Articles