Skip to content

tam-borine/GEExarray

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GEExarray

Export GEE Collections to xarray

Aims

  • Be able to export ee.ImageCollection to python xarray.Dataset objects with labelled lat,lon,time coordinates
<xarray.Dataset>
Dimensions:  (lat: 45, lon: 35, time: 1430)
Coordinates:
  * time     (time) datetime64[ns] 1900-01-01 1900-02-01 ... 2019-02-01
  * lon      (lon) float32 33.625 33.875 34.125 34.375 ... 41.625 41.875 42.125
  * lat      (lat) float32 -5.125 -4.875 -4.625 -4.375 ... 5.375 5.625 5.875
Data variables:
    precip   (time, lat, lon) float32 ...

Install

(Coming soon): pip install geexarray

Set up Google Cloud Storage (GCS)

As currently GEE exports only to Google Drive and Google Cloud Storage, we will need to use the latter as an intermediary for now. Ensure you have an account with GCS and create a project and buckets for your data.

Using GEEXarray

For each ImageCollection you want to convert to an xarray dataset, make a new instance of GEEXarray, specifying your GCS bucket name and credentials file like so:

from geexarray.api import GEEXarray

gx = GEEXarray('the_best_bucket')

gx.to_xarray(my_imagecollection, geometry_bounds_object)

The optional timeout parameter specifies how long you are happy to wait for the export from GEE. This will vary by the size of the ImageCollection you are exporting. Defaults to 10 minutes. You can reduce it by decreasing the size of geometry bounds, or filtering your ImageCollection to a narrower date range.

References

The major functions

  1. Append lat lon to imageCollection

    collection = collection.map(
        lambda im: im.addBands(ee.Image.pixelLonLat())
    )
    
  2. Append time to imageCollection

    
    

About

Export GEE Collections to xarray

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages