0

I am using Google Earth Engine, I have a FeatureCollection in which I extract a single Linestring into a "Feature" item.

(JSON output is included below)

I can extract any items from the "properties" objects using the ee.Feature.get() function.

However, I am unable to grab the coordinates from the "geometry" section.

How can I grab the coordinates of this line and export them to separate variables?

enter image description here

-edit-

I was able to find a workaround by using GIS, making table entries for begin and end X and Y values, the read the data in Earth Engine with a .getInfo() call from the new properties entries.

1 Answer 1

2

You can do it in one go, but I'm doing it in steps so you can see how to access it. First you need to take the Geometry out of the Feature. Then you access the coordinates through the geometry functions. (if you look at the print, it tells you what object is made of).

var myGeometry = myLinestring.geometry();

print(myGeometry);

var myCoordinates = myGeometry.coordinates();

print(myCoordinates);

var firstCoordinate = myCoordinates.get(0);
var lastCoordinate = myCoordinates.get(-1);

print(firstCoordinate);
print(lastCoordinate);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.