ee.FeatureCollection.copyProperties

Copies metadata properties from one element to another.

UsageReturns
FeatureCollection.copyProperties(source, properties, exclude)Element
ArgumentTypeDetails
this: destinationElement, default: null

The object whose properties to override.

sourceElement, default: null

The object from which to copy the properties.

propertiesList, default: null

The properties to copy. If omitted, all ordinary (i.e. non-system) properties are copied.

excludeList, default: null

The list of properties to exclude when copying all properties. Must not be specified if properties is.

Examples

Code Editor (JavaScript)

// Import a Landsat 8 surface reflectance image to sample.
var image = ee.Image('LANDSAT/LC08/C02/T1_L2/LC08_038032_20170722')
                // Select the optical bands.
                .select(['SR_B.']);

// Get the image geometry to define the geographical bounds of the sample.
var imageBounds = image.geometry();

// Sample the image at a set of random points; a feature collection is returned.
var pointSampleFc = image.sample(
    {region: imageBounds, scale: 30, numPixels: 5, geometries: true});

// Copy image properties to the FeatureCollection; three options follow.
print('All non-system image properties copied to the FeatureCollection',
      pointSampleFc.copyProperties(image));

print('Selected image properties copied to the FeatureCollection',
      pointSampleFc.copyProperties({
        source: image,
        properties: ['system:time_start', 'SPACECRAFT_ID']
      }));

print('All but selected image properties copied to the FeatureCollection',
      pointSampleFc.copyProperties({
        source: image,
        exclude: ['TIRS_SSM_MODEL', 'TIRS_SSM_POSITION_STATUS']
      }));