0

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?

2 Answers 2

2

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().

0

You can set the scale parameter in many functions, just set it to 20, it will perform a nearest neighbor resampling (default), if you want another algorithm like bilinear or bicubic you need to use .resample() to overwrite the default. https://developers.google.com/earth-engine/guides/resample

Your Answer

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

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