2

I have coordinates for a bounding box:

1: [-109.41397027896355,22.86994450876419]
2: [-109.41397027896355,28.00000232204317]
3: [-115.75044209344128,28.00000232204317]
4: [-115.75044209344128,22.86994450876419]

And I want to find the distance between coordinates in order to get the height and width of the bounding box in kilometers. Are there any specific functions that do this in Google Earth Engine?

2

You can get the distance between two ee.Geometry instances:

var coords = [
  [-109.41397027896355, 22.86994450876419],
  [-109.41397027896355, 28.00000232204317],
  [-115.75044209344128, 28.00000232204317],
  [-115.75044209344128, 22.86994450876419]
]

var width = distanceBetween(coords[0], coords[3])
var height = distanceBetween(coords[0], coords[1])

print(width, height)

function distanceBetween(coord1, coord2) {
  return ee.Geometry.Point(coord1).distance(
    ee.Geometry.Point(coord2)
  )
}

https://code.earthengine.google.com/da282c29504c10570984d962bd4478ed

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.