# How to construct geo\_point field from separate fields of latitude and longitude from Kafka?

**URL:** <https://discuss.elastic.co/t/how-to-construct-geo-point-field-from-separate-fields-of-latitude-and-longitude-from-kafka/333370>\
**Category:** Kibana\
**Created:** [May 14, 2023, 3:42am UTC](https://discuss.elastic.co/t/how-to-construct-geo-point-field-from-separate-fields-of-latitude-and-longitude-from-kafka/333370 "2023-05-14T03:42:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jagath\_Prasanga](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jagath_prasanga/32/120961_2.png) [@Jagath\_Prasanga](https://discuss.elastic.co/u/Jagath_Prasanga)\
**Post date:** [May 14, 2023, 3:42am UTC](https://discuss.elastic.co/t/how-to-construct-geo-point-field-from-separate-fields-of-latitude-and-longitude-from-kafka/333370/1 "2023-05-14T03:42:18Z")

</div>

How to construct geo\_point field in logstash from Kafka input? This is my logstash config file. But Kibana not recognizing as a geo\_point field.

input {

```
kafka {
        bootstrap_servers => "localhost:9095"
        topics => ["ma_readings", "sms_log"]
		decorate_events => true
}

```

}

filter {

```
json {
	source => "message"
	remove_field => ["message"]
}

if [@metadata][kafka][topic] == "ma_readings" {
	mutate{
		add_field => { "Location" => ["%{Lat}","%{Lon}"] }        		
		remove_field => ["Lat", "Lon"]
	}
	mutate {
	  convert => { "Location" => "float" }
	}
}

```

}

output {

```
elasticsearch {
	hosts => ["https://localhost:9200"]
	index => "%{[@metadata][kafka][topic]}"
	workers => 1
	user => 'logstash_internal2'
	password => 'logstash_internal2'
	ssl_certificate_verification => false

```

}

> "Location": [  
> 6.0181456,  
> 80.71436  
> ]

![image](https://us1.discourse-cdn.com/elastic/original/3X/6/6/668ba9770f66348620d6109424119be1886ce5b9.png)

---

<div class="post-metadata">

**Author:** ![Anton\_H](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anton_h/32/10200_2.png) [@Anton\_H](https://discuss.elastic.co/u/Anton_H)\
**Post date:** [May 14, 2023, 10:29am UTC](https://discuss.elastic.co/t/how-to-construct-geo-point-field-from-separate-fields-of-latitude-and-longitude-from-kafka/333370/2 "2023-05-14T10:29:17Z")

</div>

Welcome,

Just a check, but did you assign it the geopoint type in your mapping?  
see: [Geopoint field type | Elasticsearch Guide [8.7] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html)

```auto
PUT <index-name>
{
  "mappings": {
    "properties": {
      "Location": {
        "type": "geo_point"
      }
    }
  }
}

```

And according to the documentation, if you provide the geopoint as an array, the order is **lon** , **lat**. So you need to change the order in your filter.  
And maybe you need to do the conversion to float before you create the array, but I am not sure.

---

<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:** [June 11, 2023, 10:30am UTC](https://discuss.elastic.co/t/how-to-construct-geo-point-field-from-separate-fields-of-latitude-and-longitude-from-kafka/333370/3 "2023-06-11T10:30:14Z")

</div>

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