# How to select two coordinates from \[x,y,z\] array?

**URL:** <https://discuss.elastic.co/t/how-to-select-two-coordinates-from-x-y-z-array/224341>\
**Category:** Kibana\
**Created:** [March 20, 2020, 3:04am UTC](https://discuss.elastic.co/t/how-to-select-two-coordinates-from-x-y-z-array/224341 "2020-03-20T03:04:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Agrikk](https://avatars.discourse-cdn.com/v4/letter/a/7993a0/32.png) [@Agrikk](https://discuss.elastic.co/u/Agrikk)\
**Post date:** [March 20, 2020, 3:04am UTC](https://discuss.elastic.co/t/how-to-select-two-coordinates-from-x-y-z-array/224341/1 "2020-03-20T03:04:41Z")

</div>

Forgive me but I am brand. spankin'. new. to Kibana and Elastic and I'm fumbling my way through my first data set.

I have a set of json documents loaded into my first elasticsearch cluster and one of the fields is a set of coordinates like this:

```auto
"geometry": {
      "type": "Point",
      "coordinates": [
        -116.7985,
        33.5145,
        4.66
      ]
    }

```

which results in a number field

geometry.coordinates: -116.798, 33.515, 4.66

Can someone help me with what the scripted field looks like?

I would like to pull out the first two numbers as latitude and longitude to build a geo\_point field to create a coordinate map visualization.

---

<div class="post-metadata">

**Author:** ![lukeelmers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukeelmers/32/35230_2.png) [@lukeelmers](https://discuss.elastic.co/u/lukeelmers)\
**Post date:** [March 20, 2020, 5:20pm UTC](https://discuss.elastic.co/t/how-to-select-two-coordinates-from-x-y-z-array/224341/2 "2020-03-20T17:20:25Z")

</div>

Hi @Agrikk!

While you could use scripted fields to technically get the data into the shape of a geo\_point (e.g. something like this in Painless: `[params._source.geometry.coordinates[0], params._source.geometry.coordinates[1]]`), the problem you are going to run into is that the type of that field needs to be mapped to `geo_point`, and you can't currently do this in Kibana scripted fields.

Without that mapping in place, you aren't going to be able to visualize those coordinates on a map.

The best practice for a situation like this is modify your ingest to convert the data into the correct geo\_point format. Depending on your setup there are a couple ways to do this:

1. configure it in logstash as described in [Problem converting latitude and longitude into a geo point for Kibana](https://discuss.elastic.co/t/problem-converting-latitude-and-longitude-into-a-geo-point-for-kibana/52856)
2. or to update the data you have already ingested, set up an ingest pipeline in elasticsearch and reindex as described in [Reindex to add geo\_point mapping](https://discuss.elastic.co/t/reindex-to-add-geo-point-mapping/202052/2)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 17, 2020, 5:20pm UTC](https://discuss.elastic.co/t/how-to-select-two-coordinates-from-x-y-z-array/224341/3 "2020-04-17T17:20:38Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
