I have an ee.FeatureCollection with points across the globe. As a pre-processing step, I need to split it according to whether the points are in the Northern or Southern hemisphere.

Conceptually it's not a big deal, but since I am new to GEE and its JavaScript syntax, I can't get it to work.

Consider we have the FeatureCollection myPoints:

var myPoints = ee.FeatureCollection([
  ee.Feature(ee.Geometry.Point(-60,-20), {'id': 0}),
  ee.Feature(ee.Geometry.Point(140,-20), {'id': 1}),
  ee.Feature(ee.Geometry.Point(-70,10), {'id': 2}),
  ee.Feature(ee.Geometry.Point(80,40), {'id': 3}),
  ee.Feature(ee.Geometry.Point(10,50), {'id': 4}),
  ee.Feature(ee.Geometry.Point(20, -10), {'id': 5})

I think it should work something like:

  1. Define a function "GetLatitude" which gets the latitude of each point. I thought of myPoints.geometry() but I don't succeed at indexing the resulting list of lists myPoints.geometry()[0][1] is not the way to go.
  2. Define a function "FilterHemisphere" that serves as a handle to split positive latitudes to the Northern hemisphere, and negative latitudes to Southern hemisphere. JavaScript has a function Math.sign() to tell positive numbers from negative numbers, but I don't see any equivalent under Docs->ee.Number.
  3. Apply the functions to myPoints. I thought in proper GEE JavaScript it should be something like myPoints.map(GetLatitude).filter(FilterHemisphere)

I wonder if anyone could help me with defining the functions and how to apply them in proper JavaScript?

1 Answer 1


Your pseudo-code is spot on. However, earth engine has many in-built functions that make it easy to do geometric manipulations. In-built functions also run faster as they are innately parallelised.

So consider using the function ee.FeatureCollection.filterBounds(). It filters a featurecollection conditional on the geometries lying inside a pre-defined polygon. Then just define two polygons, one for north and one for south.

Here is the complete code classifying the points you defined.

enter image description here

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.