# JSON latitude/longitude to geo\_point

**URL:** <https://discuss.elastic.co/t/json-latitude-longitude-to-geo-point/1883>\
**Category:** Elasticsearch\
**Created:** [June 3, 2015, 10:44pm UTC](https://discuss.elastic.co/t/json-latitude-longitude-to-geo-point/1883 "2015-06-03T22:44:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kchiappone](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@kchiappone](https://discuss.elastic.co/u/kchiappone)\
**Post date:** [June 3, 2015, 10:44pm UTC](https://discuss.elastic.co/t/json-latitude-longitude-to-geo-point/1883/1 "2015-06-03T22:44:22Z")

</div>

I'm looking for some guidance or an example on creating a geo\_point from JSON latitude and longitude fields which I can then visualize in Kibana 4 on a Tile Map. I'm in control of the data output so I can format it any which way before Logstash processes it. Some of the examples I've seen involve mutating and converting fields which I've attempted below. This results in a "location" field in Elasticsearch with a [lon,lat] format and is displayed in Kibana as a "number" datatype. I'm unable to visualize this as a geo\_point on a Tile Map, however. I'm assuming this is because the field is mapped to a number and not a geo\_point.

Here's a snippet of what the JSON looks like (I've omitted other fields for brevity):

```
{  
   "@timestamp":"2015-06-03T22:20:44.000Z",
   "latitude":39.613658,
   "longitude":-86.106653,
   "location":[-86.106653,39.613658]
}

```

My logstash config (omitted certain values for sensitivity):

```
input {
  pipe {
    command => "..."
    type => "..."
    codec => "json"
  }
}
filter {
  json {
    source => "message"
    target => "tweet"
  }
  date {
    match => ["timestamp", "yyyy-MM-dd HH:mm:ss.SSS"]
  }
  if [latitude] and [longitude] {
    mutate {
	  add_field => ["[location]", "%{longitude}" ]
	  add_field => ["[location]", "%{latitude}" ]
  }
  mutate {
    convert => ["[location]", "float" ]
  }
}  
output {
  elasticsearch {
    host => "..."
    protocol => "http"
    cluster => "..."
    user => "..."
    password => "..."
    index => "logstash-twitter-%{+YYYY.MM.dd}"
  }
}

```

How should I map the location field to a geo\_point datatype?

I'm certain others have run into similar issues and maybe there's a simple solution that I'm not realizing or seeing online. I'm fairly new to the ELK stack so I appreciate the help. Can someone please point me in the right direction?

Thanks!

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 3, 2015, 11:20pm UTC](https://discuss.elastic.co/t/json-latitude-longitude-to-geo-point/1883/2 "2015-06-03T23:20:26Z")

</div>

You need to set the mapping manually in ES.  
Take a look at this thread for somes hint - [Kibana 4 and geoip](https://discuss.elastic.co/t/kibana-4-and-geoip/1665)

---

<div class="post-metadata">

**Author:** ![kchiappone](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@kchiappone](https://discuss.elastic.co/u/kchiappone)\
**Post date:** [June 4, 2015, 1:00am UTC](https://discuss.elastic.co/t/json-latitude-longitude-to-geo-point/1883/3 "2015-06-04T01:00:22Z")

</div>

Thank you for your reply, Mark, that was helpful. For others experiencing the same issue, here's what I did (because I couldn't really find a detailed guide on this):

Deleted my existing Logstash index template from Elasticsearch:

```
curl -XDELETE 'http://localhost:9200/_template/logstash'

```

Modified the following template JSON file (make sure to back it up first):

```
/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-0.2.4-java/lib/logstash/outputs/elasticsearch/elasticsearch-template.json

```

In the "properties" section, I added "location" and made it a "geo\_point" type (note: geoip already existed):

```
"properties" : {
         "@version": { "type": "string", "index": "not_analyzed" },
         "geoip" : {
           "type" : "object",
             "dynamic": true,
             "properties" : {
               "location" : { "type" : "geo_point" }
             }
         },
         "location" : { "type": "geo_point" }
       }

```

In Kibana, I deleted the existing logstash index pattern and re-created it. Now the "location" field is mapped to a "geo\_point" and I'm able to visualize it on the Tile Map.

Thanks again!

---

<div class="post-metadata">

**Author:** ![spraveenjd](https://avatars.discourse-cdn.com/v4/letter/s/a698b9/32.png) [@spraveenjd](https://discuss.elastic.co/u/spraveenjd)\
**Post date:** [July 11, 2016, 8:17pm UTC](https://discuss.elastic.co/t/json-latitude-longitude-to-geo-point/1883/4 "2016-07-11T20:17:39Z")

</div>

> [@kchiappone](#):
>
> string

"properties" : {  
"@timestamp": { "type": "date", "doc\_values" : true },  
"@version": { "type": "string", "index": "not\_analyzed", "doc\_values" : true },  
"geoip" : {  
"type" : "object",  
"dynamic": true,  
"properties" : {  
"ip": { "type": "ip", "doc\_values" : true },  
"location" : { "type" : "geo\_point", "doc\_values" : true },  
"latitude" : { "type" : "float", "doc\_values" : true },  
"longitude" : { "type" : "float", "doc\_values" : true }  
}  
},  
"location": {  
"type": "geo\_point"  
}  
}

I am using like this and I deleted my \_template/logstash. After that I view the \_template/logstash using curl -XGET

"properties": {  
"@timestamp": {  
"doc\_values": true,  
"type": "date"  
},  
"location": {  
"type": "geo\_point"  
},  
"geoip": {  
"dynamic": true,  
"properties": {  
"location": {  
"doc\_values": true,  
"type": "geo\_point"  
},  
"longitude": {  
"doc\_values": true,  
"type": "float"  
},  
"latitude": {  
"doc\_values": true,  
"type": "float"  
},  
"ip": {  
"doc\_values": true,  
"type": "ip"  
}  
},  
"type": "object"  
},  
"@version": {  
"index": "not\_analyzed",  
"doc\_values": true,  
"type": "string"  
}  
},  
"\_all": {  
"enabled": true,  
"omit\_norms": true  
}

Kibana it is still shows as string  
location.lon string   
Edit  
location.lat string

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 11, 2016, 8:44pm UTC](https://discuss.elastic.co/t/json-latitude-longitude-to-geo-point/1883/5 "2016-07-11T20:44:06Z")

</div>

Please start your own thread, this one is a year old!

---

<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:** [July 5, 2017, 10:36pm UTC](https://discuss.elastic.co/t/json-latitude-longitude-to-geo-point/1883/6 "2017-07-05T22:36:24Z")

</div>


