I try to export a FeatureCollection to my assets, this featurecollection is build as such:

surface_deforested_coffee = ee.Image.pixelArea().divide(10000).multiply(deforestation_total)
res_existing = surface_deforested_coffee.reduceRegions(
  collection = fc,
  reducer = ee.Reducer.sum().setOutputs(["confirmed_deforestation"]),
  scale = 50,

with fc being a collection of farm circles.

When I start the task in GEE:

task = ee.batch.Export.table.toAsset(
  collection = res_existing,
  description = "deforestation_on_existing_coffee",
  assetId = "users/bornToBeAlive/ldc_test/Son_La_deforestation"

I get the following error:

Error: Unable to export features with empty geometry. (Error code: 3)

which surprises me bacause I manually created this feature collection by buffering Points. There should be no empty geometry.

So to debug my code I would like to know if it's possible to check for empty geometries in a ee.FeatureCollection?

2 Answers 2


reduceRegions just copies the input feature and adds some properties to it, so in order to have empty geometries, you had to start out with them that way. Buffering something with no geometry results in no geometry.

Unfortunately, most of the methods for detecting null properties wont work for geometries. None of these work (I filed a bug for them):

  • ee.Filter.hasType(".geo", "Geometry")
  • ee.Filter.notNull([".geo"])
  • ee.Filter.area(0, 1e12)
  • ee.Filter.eq(".geo", null)

What does seem to work is filtering to see if the geometry is contained in a global polygon (use a 6-point poly to ensure it spans the whole globe).

WORLD = ee.Geometry.Polygon([-180, 88, 0, 88, 180, 88, 180, -88, 0, -88, -180, -88])
collection.filter(ee.Filter.isContained(".geo", WORLD))

The downside is that that is an expensive test. That might take a while (or, if you have really complex geometries, it might OOM). If you know the collection only contains points, lines or Polygons, then something like this works:

  • ee.Filter.hasType(".geo", "Point")

But you'll probably miss the complex geometries like MultiPolygon, GeometryCollection, etc, so that's perilous.



This may be relevant: I wanted to clip a set of images by reducing their footprint by -500 meters, but some of them may be too small and the clipping returns error. To do this through a map function, I did it this way in python (should be the same in JS):

def reduceFootprint(image):
    new_footprint = image.geometry().buffer(-500)
    # Set a flag if the reduced footprint will shrink down the image to null. 
    # If this is true, no footprint reduction is made. Otherwise image is clipped.
    flag = ee.Algorithms.IsEqual(new_footprint.area(),ee.Number(0))
    return ee.Algorithms.If(flag, image, image.clip(new_footprint))

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.