1

I am making a time-series plot with data extracted from a point, and I would like to include the point coordinates in the title text.

e.g. 'Timeseries from point (61.08457, 6.03583)'

However, I can't see how to get the coordinates as a simple string object that can be concatenated neatly.

See the code below.

var centre_pt = (ee.Geometry.Point(6.10736, 61.49845));

var coordinates = (centre_pt.coordinates())
var lat = ee.Number(coordinates.get(1)).format('%.6f')
var long = ee.Number(coordinates.get(0)).format('%.6f')
var coordinates = (ee.String('(').cat(long).cat(', ').cat(lat).cat(')'));  

print(coordinates)

var title = ('Timeseries from point: ' + coordinates)
print(title)

When I print it, it comes up as:

Timeseries from point: ee.String({
  "type": "Invocation",
  "arguments": {
    "string1": {
      "type": "Invocation",
      "arguments": {
...etc

I don't want all the extra bits. How do I get just the coordinates to use in a concatenated string?

1 Answer 1

1

The problem is with the title variable. It needs to be treated as an ee.String and cat() with the coordinates.

var title = ee.String('Timeseries from point: ').cat(coordinates)

Also, the 'coordinates' variable is overwritten here. You can rename the first one or simply avoid it.

var lat = ee.Number(centre_pt.coordinates().get(1)).format('%.6f')
var long = ee.Number(centre_pt.coordinates().get(0)).format('%.6f')
var coordinates = (ee.String('(').cat(long).cat(', ').cat(lat).cat(')')); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.