TransWikia.com

sampleRegions deleting input feature collection properties, how to stop that?

Geographic Information Systems Asked by Eben Broadbent on December 21, 2020

How do I retain the existing properties of an input feature collection to sampleregions, as well as the ones that it extracts from the images? When I leave it to default it deletes the input properties and only has the image extracted values.

One Answer

You can define the argument properties to do that. See the explanation GEE provides in the documentation on sampleRegion():

properties (List, default: null): The list of properties to copy from each input feature. Defaults to all non-system properties.

An example would be:

// define sample image and feature collection
var sampleFeatCol = ee.FeatureCollection([
  ee.Feature(point1, {prop1: 1, prop2: 2, 'system:time_start': 10000}),
  ee.Feature(point2, {prop1: 2, prop2: 1, 'system:time_start': 10000})]);
var image = ee.Image(1);

// define the properties to retain
var listProperties = ['prop1','system:time_start'];

sampleFeatCol = image.sampleRegions(sampleFeatCol, listProperties, 100)

print(sampleFeatCol)

link example code

Answered by Kuik on December 21, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP