How to filter a Google Earth Engine Image Collection by crs?

718 Views Asked by At

I have a script to download Sentinel-1 images from Google Earth Engine, which works perfectly over UK regions and other parts of Europe. However, when I try to run it for a region of Norway, the image returned is blurred. I think this is because within the ee.imagecollection some of the images have a different crs projection.

Hence, my question is how do I filter the images to remove images with the other crs? Here is an example of how it looks in Google Earth Engine:

Sentinel-1 image of area of Norway in Google Earth Engine

and here is how a print out of the image collection looks like in Google Earth Engine showing the two projections (see features 0 and 3 showing EPSG: 32632 and EPSG 32633):

Print out in Google Earth Engine of Norway image collection

My Google Earth Engine Script is included below. To replicate the problem replace the Norway geometry with a drawn polygon.

var year = 2021;
var region = 9;
var mth = 'October';
var mthno1 = 10;
var mthno2 = 11;
var endday1 = 18;
var endday2 = 18;
var geometry = ee.FeatureCollection("users/nfigbfr/Norway");

var s1c = ee.ImageCollection('COPERNICUS/S1_GRD')
        .filterBounds(geometry)
        .filterDate(year+'-'+mthno1+'-'+endday1,year+'-'+mthno2+'-'+endday2)
        .filter(ee.Filter.eq('transmitterReceiverPolarisation', ['VV','VH']))
        .filter(ee.Filter.eq('instrumentMode', 'IW'))
        .map(function(image) {
          var edge = image.lt(-30.0);
          var maskedImage = image.mask().and(edge.not());
          return image.updateMask(maskedImage);
        });
print(s1c)
var img = s1c.mean();

print(img)  
var img = img.addBands(img.select('VV').subtract(img.select('VH')).rename('Ratio'));
var img = img.select(['VV','VH','Ratio']).toFloat();
print(img);

var img_display = img.select(['VV','VH','Ratio']).clip(geometry);
Map.centerObject(geometry);
Map.addLayer(img_display, {min: -25, max: 0});

Export.image.toDrive({ 
image: img,
description: 'Norway_mean_'+mth+year,
folder: 'Sentinel_1',
crs: 'EPSG:32632',
scale: 10, 
maxPixels: 1e13, 
region: geometry 
});
1

There are 1 best solutions below

0
On

The crs is a property of individual bands, not the images. I also haven't been able to find out if/how we can access the band properties for filtering.

However, here is a workaround:

var target_crs = 'EPSG:32671'
var s1c = ee.ImageCollection('COPERNICUS/S1_GRD')
        .filterBounds(point)
        .filterDate(year+'-'+mthno1+'-'+endday1,year+'-'+mthno2+'-'+endday2)
        .filter(ee.Filter.eq('transmitterReceiverPolarisation', ['VV','VH']))
        .filter(ee.Filter.eq('instrumentMode', 'IW'))
        .map(function(image) {
          var edge = image.lt(-30.0);
          var maskedImage = image.mask().and(edge.not());
          return image.updateMask(maskedImage);
        })
        .map(function(img){
          var crs = img.select(['VV']).projection().crs()
          var myImageWithProperties = x.set({
          crs: crs})
          return ee.Image(myImageWithProperties)
          ;})
        .filter(ee.Filter.eq('crs', target_crs));

I added a .map() function that grabs the projection code (EPSG) from the VV band and sets it as an image property. Then we can filter the collection based on this property.

I've tried this on Sentinel-2 and it works fine. Still curious if there is a simpler way, though.

PS: this question is better suited for https://gis.stackexchange.com