1

I have two feature collections- a feature collection of different polygons (primary collection) and a .csv with various location data (secondary collection). I would like to append each column in the secondary collection to the each feature in the primary collection.

As it is now, I have a list of features (columns in secondary collection) appended to each feature in the primary collection, but when I export the data to a csv, all that shows up is a column with <Feature> in each column.

Here is my "secondary" feature collection. I would like to have these columns in the output csv:

Here is my secondary feature collection

Here is a snippet of the output CSV. See that "points" is the name of the secondary feature collection, and information such as Species, and No_Fish is lost.

Here is my output CSV

Here is my pseudo-code solution, extracting properties from an already joined feature collection:

for feature in joined:

    feat_points = feature.get("Points")

    //Iterate over each point in secondary collection that has been joined
    for point in feat_points:

        //Set each property name in secondary collection to primary collection
        for property in point: 
            feature.set("Property_name",property)

Here is a link to my code: https://code.earthengine.google.com/a3ff4b90ac87ccc9199ad4861a9d4f54

1 Answer 1

1

The 'Points' property is a list of features which pass the geo-join. You will need to map over the joined collection to get each of the secondary features'properties. I assume you would like to keep all properties from the primary feature, and append the properties of the secondary which pass the geo-join? You could do that as follows:

// add the properties of each feature secondary feature to each primary
var feats = studyHUCs.map(function(primary){
  var secondaries = ee.FeatureCollection(ee.List(primary.get('Points')));
  // append primary properties
  return secondaries.map(function(secondary){
    return secondary.set(primary.toDictionary().remove(['Points']));
  });
}).flatten();
print(feats);

link code

2
  • That's correct, I would like to append the properties of secondary which pass the geo-join. However, each feature in the primary may have multiple secondaries which pass. A cursory glance indicates that feats only ever has 1 secondary appended. How would you recommend I keep information from each different secondary within the studyHUCs boundaries? Commented Jun 7, 2020 at 17:39
  • I think that does do it? link. I think you deleted or renamed the asset, so I cannot check
    – Kuik
    Commented Jun 7, 2020 at 21:24

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.