0

I have to import a MultiPolygon in Google Earth Engine

and what I have is just this.

 {"type": "GeometryCollection", "geometries": [{"type": "MultiPolygon","coordinates": [[[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]], [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]], [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]]}]}

I think this is of GeoJSON Format correct me if I am wrong.

Please explain how to import it as a MultiPolygon.

1 Answer 1

2

Simply add the coordinates as a MultiPolygon geometry.

var multipoly = ee.Geometry.MultiPolygon(
  [[[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]], [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]], [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]]
)

Map.addLayer(multipoly)
1
  • How would you import this if the GeoJSON had mixed geometry types (e.g. points, polygons, etc) and wanted to add it to the Map.drawingTools().addLayer as a geometry layer?
    – l_r
    Oct 20, 2021 at 19:07

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.