2

I would like to get the numpy arrays of some Google Earth Engine collection.

For example here my intent would be to obtain a 4d numpy array with dimensions [timestamp, height, width, bands] (or whatever order) with the Sigma0 data of a given region, defined by its bounds (here in UTM projection).

e.g.

import ee
import geopandas as gpd
from shapely.geometry import box

ee.Initialize()

crs = {'init': 'epsg:32628'}
poly = gpd.GeoSeries(box(578150.0, 1572350.0, 578350.0, 1572550.0), crs=crs)

poly_json = eval(poly.to_json())
gj_geom = poly_json['features'][0]['geometry'] 
geom = ee.Geometry(gj_geom, poly.crs['init'][5:])

collection = (ee.ImageCollection('COPERNICUS/S1_GRD')
              .filter(ee.Filter.date('2019-01-01', '2019-02-1'))
              .filter(ee.Filter.geometry(geom))
             )

How do I obtain the raw data arrays from the filtered collection?

2

1 Answer 1

4

You can use ee.Image.sampleRectangle() (see this post) for converting GEE images to 2d array. However, there is a limit of 262144 pixels that can be transferred to protect your system from becoming unresponsive.

So for your collection, you can map over a function that applies this sampleRectangle and retrieves the respective array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.