# Converting Location field into lat and long

**URL:** <https://discuss.elastic.co/t/converting-location-field-into-lat-and-long/152776>\
**Category:** Kibana\
**Created:** [October 17, 2018, 8:18am UTC](https://discuss.elastic.co/t/converting-location-field-into-lat-and-long/152776 "2018-10-17T08:18:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gauti](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Gauti](https://discuss.elastic.co/u/Gauti)\
**Post date:** [October 17, 2018, 8:18am UTC](https://discuss.elastic.co/t/converting-location-field-into-lat-and-long/152776/1 "2018-10-17T08:18:17Z")

</div>

Hi All,

We have a field name "Location" which is getting into elasticsearch as a string value, how can i split this location field into latitude and longitude to visualize it as a coordinate map.

Is there any way to achieve this?

Thanks  
Gauti

---

<div class="post-metadata">

**Author:** ![fkelbert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fkelbert/32/35762_2.png) [@fkelbert](https://discuss.elastic.co/u/fkelbert)\
**Post date:** [October 17, 2018, 8:51am UTC](https://discuss.elastic.co/t/converting-location-field-into-lat-and-long/152776/2 "2018-10-17T08:51:22Z")

</div>

You probably want to change how you are ingesting data into Elasticsearch. It will make sense to change the field mapping to type [`geopoint`](https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html) and to index accordingly. In Kibana, visualizations should then work out of the box.

---

<div class="post-metadata">

**Author:** ![Gauti](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Gauti](https://discuss.elastic.co/u/Gauti)\
**Post date:** [October 17, 2018, 9:34am UTC](https://discuss.elastic.co/t/converting-location-field-into-lat-and-long/152776/3 "2018-10-17T09:34:24Z")

</div>

@fkelbert i'm using logstash to fetch data from a rest source, if i directly map the "Location" field as a geopoint it simply does not index the data, as far as i know we can map the location only by lat and long fields.

Do you have any suggestions for achieving this?

Thanks  
Gauti

---

<div class="post-metadata">

**Author:** ![fkelbert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fkelbert/32/35762_2.png) [@fkelbert](https://discuss.elastic.co/u/fkelbert)\
**Post date:** [October 17, 2018, 10:04am UTC](https://discuss.elastic.co/t/converting-location-field-into-lat-and-long/152776/4 "2018-10-17T10:04:24Z")

</div>

The first thing you will need to do is to change the field mapping in Elasticsearch to `geopoint`.

You will then need to change your Logstash pipeline to transform your input data from the rest source into the expected format. The documentation I have linked lists several examples that show the required format of the data to be indexed.

Without knowing the structure of your data, it is not possible to advise in more detail.

---

<div class="post-metadata">

**Author:** ![Gauti](https://avatars.discourse-cdn.com/v4/letter/g/cdc98d/32.png) [@Gauti](https://discuss.elastic.co/u/Gauti)\
**Post date:** [October 22, 2018, 9:47am UTC](https://discuss.elastic.co/t/converting-location-field-into-lat-and-long/152776/5 "2018-10-22T09:47:28Z")

</div>

hey @fkelbert , sorry for late response,

This is how my document looks like,

\<result\>  
\<close\_code\>Closed/Resolved by Caller\</close\_code\>  
\<assignment\_group\>Service Desk\</assignment\_group\>  
\<description\>User can't access email on mail.company.com.\</description\>  
\<child\_incidents/\>  
\<closed\_by\>System Administrator\</closed\_by\>  
\<number\>INC0000001\</number\>  
\<contact\_type\>Chat Bot\</contact\_type\>  
\<urgency\>1 - High\</urgency\>  
\<sys\_created\_on\>2014-02-19 10:24:13\</sys\_created\_on\>  
\<problem\_id\>PRB0000007\</problem\_id\>  
\<caller\_id.location.longitude/\>  
\<company/\>  
\<state\>Closed\</state\>  
\<reassignment\_count\>1\</reassignment\_count\>  
\<caller\_id.location.latitude/\>  
\<sys\_created\_by\>pat\</sys\_created\_by\>  
\<assigned\_to\>Charlie Whitherspoon\</assigned\_to\>  
\<knowledge\>false\</knowledge\>  
\<severity\>1 - High\</severity\>  
\<closed\_at\>2015-07-22 16:10:06\</closed\_at\>  
\<cmdb\_ci\>MailServerUS\</cmdb\_ci\>  
\<impact\>1 - High\</impact\>  
\<reopen\_count/\>  
\<priority\>1 - Critical\</priority\>  
\<escalation\>Normal\</escalation\>  
\<resolved\_at\>2015-10-21 12:56:12\</resolved\_at\>  
**\<location\>Oklahoma\</location\>**  
\<category\>Network\</category\>  
\</result\>

That highlighted location field is what i need to show it in maps, how can i achieve this.

Thanks  
Gauti

---

<div class="post-metadata">

**Author:** ![fkelbert](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fkelbert/32/35762_2.png) [@fkelbert](https://discuss.elastic.co/u/fkelbert)\
**Post date:** [October 22, 2018, 10:11am UTC](https://discuss.elastic.co/t/converting-location-field-into-lat-and-long/152776/6 "2018-10-22T10:11:00Z")

</div>

You need some way to convert this information into lat,lon.

[This thread](https://discuss.elastic.co/t/elasticsearch-find-latitude-and-longitude-from-city-name/52644) discusses the very same topic. I'm afraid you won't be pleased by the answers -- the functionality you are looking for is not available out of the box.

---

<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:** [November 19, 2018, 10:11am UTC](https://discuss.elastic.co/t/converting-location-field-into-lat-and-long/152776/7 "2018-11-19T10:11:01Z")

</div>

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