I want to add a property to each element of a Feature Collection using rgee. This feature collection I have is just a list of polygons, and I want to add an ID (which is different) for each of these geometries. So far, I have:
library(rgee)
library(dplyr)
library(readr)
#Read polygons
collection <- read_rds("polygons.rds")
# convert collection to feature collection using sf_as_ee
featcol <- sf_as_ee(collection$geometry)
So for each element of this collection, I want to add a property called site_no (site number)
site_no <- collection$site_no
If I do:
withMoreProperties = featcol$map(function(f) {
# Set a property.
f$set("site_no", site_no)
})
It doesn't work, instead of adding one site number to each element, it adds all site numbers to all the sites.
Any suggestions on how to fix this? maybe using a loop? or an ee$List?