Considering this FeatureCollection:

var fc = ee.FeatureCollection([
  ee.Feature(null, {x1: 0.1, x2: 10, x3: "a", x4: 1.1}),
  ee.Feature(null, {x1: 0.2, x2: 9, x3: "b", x4: 2.2}),
  ee.Feature(null, {x1: 0.3, x2: 8, x3: "c", x4: 3.3}),
  ee.Feature(null, {x1: 0.4, x2: 7, x3: "d", x4: 4.4}),
  ee.Feature(null, {x1: 0.5, x2: 6, x3: "e", x4: 5.5}),
  ee.Feature(null, {x1: 0.6, x2: 5, x3: "f", x4: 6.6})

How do I select only column x3 based on data type string?

I'm not referring to this method: fc.select("x3").

1 Answer 1


If you mean you want to know the data type for all the columns and then select one or more of them based on that type, then you'd need to map over the properties of one of the features or, if the collection has a schema, get it with Describe, and map over that to test the type of each column:

var desc = ee.Dictionary(ee.Algorithms.Describe(fc))
var cols = ee.Dictionary(desc.get('columns'))
var stringCols = cols.map(function(k, v) { 
    return ee.Algorithms.If(ee.Algorithms.IsEqual(v, "String"), k, null)
  • I have completely missed ee.Algorithms.Describe(). Functionality like that is something I've been looking for other use-cases. How "expensive" is it - larger tables for example? Commented May 5, 2022 at 20:37
  • It doesn't descend into collections; it only describes the outermost object. Commented May 6, 2022 at 9:16

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.