I have imported a CSV file with just one column. Each row of the column has multiple coordinates required to draw a polygon. (This was collected on the ground)

I have used the below code to extract the coordinates from the CSV as a list

var poly = table2.aggregate_array('wkt')  //wkt being the column name

Now essentially, I would want to loop through the list, create and display the polygons on the map.

I am looking for something like this:

var newPolygon = ee.Geometry.Polygon(poly[i])

If there is a simpler way to use the coordinates to plot polygons can you let me know?

  • I found a way around this problem by ingesting the CSV file with polygon coordinates into QGIS and converting it to a polygon shapefile. Now I am able to use this table in Google Earth Engine directly to create map layers and conduct other operations. Commented Mar 9, 2020 at 4:47

1 Answer 1


Without more information on the CRS of your coordinates, and their construction., it will be difficult to create a working solution, but I'll make assumptions along the way and see if you can adapt it to your solution. What you'll want to do is map a function to your list that will take each element of the list (the polygon coordinates) and make a geometry with it. Something like this.

var makeFeatureFromGeometry = function(coords){
         var newGeometry = ee.Geometry.Polygon(coords, CRS); // you will have to supply the CRS of the coordinates
         return ee.Feature(newGeometry);
var myFeatureCollection = ee.FeatureCollection(poly.map(makeFeatureFromGeometry));


Try this and if you receive error messages, I'll see if I can help you create a working solution.

  • Thanks for the response @Sean! This was exactly the gap in my understanding. However, I am now facing an error with coords, as it is of type string and I am unable to convert it to list despite trying out a lot of functions. The error I am getting while constructing the polygon is: "GeometryConstructors.Polygon, argument 'coordinates': Invalid type. Expected: List<Object>. Actual: String." Commented Feb 14, 2020 at 9:28
  • My coordinates are of the format: [[76.47441303,11.91755698],[76.47439336,11.91753608],[76.47435523,11.91751293],[76.47429992,11.91750973],[76.47426618,11.91756832],[76.47436792,11.91753208],[76.47452594,11.91749775],[76.47441303,11.91755698]] This is accepted while directly using it in ee.Geometry.polygon But not while mapping it is as variable coors Commented Feb 14, 2020 at 9:52
  • Hi Abheeshta, do the following: print(poly) and look in the console what appears. It might be a text string, which is why you can't read it with the function I wrote. It is expecting a list... Commented Feb 15, 2020 at 23:13
  • Yes, it is a text string. When I try to parse it to a list using JSON.parse it throws an error saying "element e is not found at position 0" Commented Feb 17, 2020 at 1:46
  • Look in the docs of the code editor, under ee.String. perhaps if you cast it to an ee.String() you will then be able to use the functions there to parse it. I've never used wkt with Earth Engine, so I'm afraid I'm not much help. Commented Feb 17, 2020 at 10:17

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.