I look at several Sentinel 1 GRD images and want to calculate the median for multiple regions for every image inside the image collection. First, I create an image collection by filtering dates and bounds:
geojsonFc= ee.FeatureCollection({
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[ [
8.4574556350708,
49.853355306121884
], [
8.460803031921387,
49.853355306121884
], [
8.460803031921387,
49.85692454014551
], [
8.4574556350708,
49.85692454014551
], [
8.4574556350708,
49.853355306121884
]]]}}]})
s1_grd = ee.ImageCollection('COPERNICUS/S1_GRD').filterBounds(geojsonFc).filterDate(ee.Date('2018-06-01'), ee.Date('2018-06-30'))
Within the second step, I map a reducer function over the collection
s1_grd_rr = ee.FeatureCollection(s1_grd.map(lambda x: x.reduceRegions(collection=geojsonFc,reducer='median', crs='EPSG:4326',scale=10)))
Now I got a FeatureCollection with several FeatureCollections containing the median of all bands and corresponding geometries and coordinates. I want to transform this information back into a raster(ee.Image). I think the reduceToImage function suits best for this purpose.
Here is an example for the first FeatureCollection from s1_grd_rr
test = ee.FeatureCollection(s1_grd_rr.first()).filter(ee.Filter.notNull(['VV'])).reduceToImage(properties=['VV'], reducer=ee.Reducer.first())
Now I have an ee.Image.
test.getInfo()
{'type': 'Image', 'bands': [{'id': 'first', 'data_type': {'type': 'PixelType', 'precision': 'double'}, 'crs': 'EPSG:4326', 'crs_transform': [1, 0, 0, 0, 1, 0]}]}
Now i want to display these image in Ipython and I try:
import IPython.display as disp
url = test.select('first').getThumbURL({'min': -20, 'max': 0})
disp.Image(url=url, width=800)
But now i get these error:
EEException: Image is unbounded. Must specify a region or a pixel grid with dimensions.
Any ideas what I am doing wrong? I mean, the error say what i have to do. I have to specify a region, but i don't know how to do that ;)