TransWikia.com

Extracting Geometry Coordinate from a feature

Geographic Information Systems Asked by user174442 on June 18, 2021

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.

One Answer

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);

Correct answer by Sean Roulet on June 18, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP