Hi, can I have a list like [ 6.8958, 52.2183 ] being generated as attribute value, with latitude, longitude being randomly chosen?
You can turn any data type into an array by adding brackets to the name. For example location[2] for two values or location[2-4] for between 2 and 4 values.
In this particular case, a better approach would be to use a formula to combine latitude and longitude fields into an array. For example the following formula will create an array from two fields called __lat and __long:
[__lat, __long]
Note that any fields named starting with two underscores are automatically hidden from the output. This is a useful trick when composing columns using formulas.
Thank you. I am getting closer. But using the formula above, I end up getting strings as latitude and longitude, rather than numbers. How to change this?
This is what I get:
“location”: [
“23.9”,
“54.88333”
]
This is what I need:
“location”: [
23.9,
54.88333
]
Found it myself: [ __longitude.to_f, __latitude.to_f ] does the trick. Good stuff.
Yep, that’s the way to do it.