Google Earth Engine – Correct Order of Resampling, Reprojecting, and Composing ImageCollection

compositecoordinate systemgoogle-earth-enginegoogle-earth-engine-python-apiresampling

I want to resample, reproject and compose an image collection in python using the GEE API.
My script now is this

adm0 = ee.FeatureCollection("FAO/GAUL/2015/level0");
filter = ee.Filter.inList('ADM0_NAME', ['Philippines'])
phil = adm0.filter(filter)
roi = phil.geometry()

startDate = '2018-01-20'
endDate = '2018-01-28'

sentinel1_vh = ee.ImageCollection('COPERNICUS/S1_GRD')\
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH')).select('VH')\
.filter(ee.Filter.eq('instrumentMode', 'IW'))\
.filter(ee.Filter.eq('resolution_meters', 10))\
.filter(ee.Filter.date(ee.Date(startDate), ee.Date(endDate)))\
.filter(ee.Filter.bounds(roi))

def resample_and_reproject(image):
    return image.reduceResolution(reducer = ee.Reducer.mean()).reproject(crs = 'EPSG:32651', scale = 20)

sentinel1_vh_new = sentinel1_vh.map(resample_and_reproject)
medianComposite = sentinel1_vh_new.median()

So as you can see, the images in the ImageCollection sentinel1_vh have a pixel size of 10m, but I want the images to have a pixel size of 20m (using a .mean() operation). I also want to reproject the images to the crs EPSG:32651. And lastly, I want to compose one image of this ImageCollection using a .median() operation. But if I run this script and ask for medianComposite.getInfo(), I get

{'bands': [{'crs': 'EPSG:4326',
   'crs_transform': [1, 0, 0, 0, 1, 0],
   'data_type': {'precision': 'double', 'type': 'PixelType'},
   'id': 'VH'}],
 'type': 'Image'}

it seems that this is not what I want. Who can help me out?

Best Answer

When you make a composite from a collection, the resulting collection will always report a “default default projection” of EPSG:4326, because the collection is made from images which may have arbitrarily different projections (so their pixel grids may even be “askew” to each other and not in any way describable as the same coordinate system). This result does not indicate that your reprojection has not taken effect.

You can use the Image.setDefaultProjection() algorithm after median() to “fix” this, but this doesn't affect the pixel values — it only affects what you see printed, and any future operations that use the default projection via Image.projection().

Related Question