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?

asked Nov 22, 2019 at 11:08
2
  • Is this the duplicated question: gis.stackexchange.com/questions/309195/…? Commented Feb 13, 2020 at 17:51
  • @Vincent indeed that answers my question, thanks for pointing to it Commented Feb 13, 2020 at 23:26

2 Answers 2

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.

answered Apr 15, 2020 at 0:18
0

It's possible to export google earth engine image to local files using geemap library.

import geemap
import numpy as np
band_names = image.bandNames().getInfo() # List with band names
selected_band = image.select(band_name) # selected band to trnasform
image_array = geemap.ee_to_numpy(selected_band, region=geometry) # Client side
ndvi_array = np.squeeze(ndvi_array) # Deleting single-dimensional axis
answered May 22, 2024 at 23:46

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.