0

I am fairly new to the Google Earth Engine platform, and I want to create a dataset for my machine learning project using the aforesaid platform. As far I have this code for downloading a single picture:

import ee
 
# Trigger the authentication flow.
ee.Authenticate()
 
# Initialize the library.
ee.Initialize()

geoJSON = ... # coordinates of rectangle
coords = geoJSON['features'][0]['geometry']['coordinates']
aoi = ee.Geometry.Polygon(coords)

ffa_db = ee.Image(ee.ImageCollection('COPERNICUS/S1_GRD') 
                       .filterBounds(aoi) 
                       .filterDate(ee.Date('2020-08-01'), ee.Date('2020-08-31')) 
                       .first() 
                       .clip(aoi))

url = ffa_db.select('VV').getThumbURL({'min': -20, 'max': 0})

After that, I just download a file with this command: !wget {url} (From Jupyter Notebook) The question is fairly simple, but I had much struggled with it due to the lack of Pythonic ways of doing such things. I searched GEE Community tutorials and Github, but have no luck with them.

How can I download RGB images from Sentinel-2 using Python?

Better to download to a local directory rather than a Google disk.

2
  • 1
    what is wrong with the method you exposed? As far as I see you are downloading the image – Rodrigo E. Principe Jan 17 at 20:21
  • @RodrigoE.Principe this code sample is working, but how should I modify it to download images from COPERNICUS/S2 in RGB, because by changing ImageCollection to ImageCollection('COPERNICUS/S2') and selected bands to ffa_db.select('B4', 'B3', 'B2') gives me blank image. I guess I don't understand how bands works, or I don't know what is the problem. I hope I have explained the problem. – Петр Воротинцев Jan 18 at 9:02
2

You could try to define visualization parameters and then make a new variable where you add the visualization. It would look something like this:

var vis = {
  min: 0,
  max: 3000,
  bands:['B4','B3','B2'],
};          

var ffa_db_new = ffa_db.visualize(vis);

And then you export the new variable ffa_db_new instead of the old one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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