1

Say I am calculating some numbers in some way and I end up needing to create some geometries based on those numbers. The simplest example would be:

var bboxList = ee.List([1,2,8,9]) // assume this has been calculated in gee
// the below line should, in my opinion, work, but it doesn't,
// because ee.Geometry.BBox can only handle client-side objects
var myBbox = ee.Geometry.BBox(bboxList.get(0),bboxList.get(1),bboxList.get(2),bboxList.get(3))
// what finally works is getting the server-side object to the client-side,
// but this is highly discouraged
var myBbox = ee.Geometry.BBox(bboxList.get(0).getInfo(),bboxList.get(1).getInfo(),bboxList.get(2).getInfo(),bboxList.get(3).getInfo())

Is there a way to create geometries, without passing all their coordinates by the client? It is obviously not an issue when there's only 4 coordinates, but one can easily imagine this becoming an issue with thousands, or millions of coordinates sent back and forth.

1 Answer 1

1
// the below line should, in my opinion, work, but it doesn't,
// because ee.Geometry.BBox can only handle client-side objects
var myBbox = ee.Geometry.BBox(bboxList.get(0),bboxList.get(1),bboxList.get(2),bboxList.get(3))

It's a bug that this doesn't work. In fact, it will work if you run it with the Python version of the EE client instead of JavaScript.

I'll look into it and update this answer when it's fixed.

2
  • thanks. I also tried to create geometries in a .map, which, for understandable reasons, would not be able to work with client-side values. Ultimately, I conceded (popular word nowadays), and calculated everything on the client side, but that only worked because I don't really have millions of coordinates. It was also very cumbersome because I work in the code editor, which is stuck on Caja's ECMA script 5. Any insider's news on the code editor moving from Caja, or updating Caja? Or should I just concede and move out of the code editor?
    – Andrei
    Commented Nov 12, 2020 at 15:09
  • 1
    @Andrei Can't promise any schedule, but we're aware the outdated language is a problem! If nothing else, => functions would make lots of Earth Engine code tidier.
    – Kevin Reid
    Commented Nov 12, 2020 at 16:37

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.