# Logstash: convert lambert to latitude and logitude

**URL:** https://discuss.elastic.co/t/logstash-convert-lambert-to-latitude-and-logitude/58915
**Category:** Logstash
**Created:** [August 25, 2016, 10:24am UTC](https://discuss.elastic.co/t/logstash-convert-lambert-to-latitude-and-logitude/58915 "2016-08-25T10:24:00Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![sen](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@sen](https://discuss.elastic.co/u/sen)
#### Post date: [August 25, 2016, 10:24am UTC](https://discuss.elastic.co/t/logstash-convert-lambert-to-latitude-and-logitude/58915/1 "2016-08-25T10:24:00Z")

</div>

Hello folks,

I am working on a project where I have in my input data some coordinates in lambert. i would like to convert these coordinates in latitude and longitude. I found on internet a function in ruby to do it: [https://github.com/yageek/lambert-ruby](https://github.com/yageek/lambert-ruby) . However, I don't think I can use it in logstash. Then, do you know if there is a function or a plugin in logstash.

Thank you for your attention and your help.

S

---

<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: [August 25, 2016, 11:44am UTC](https://discuss.elastic.co/t/logstash-convert-lambert-to-latitude-and-logitude/58915/2 "2016-08-25T11:44:27Z")

</div>

Unless lambert is some kind of cheese, you may need to explain what it is.

---

<div class="post-metadata">

### Author: ![sen](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@sen](https://discuss.elastic.co/u/sen)
#### Post date: [August 25, 2016, 11:48am UTC](https://discuss.elastic.co/t/logstash-convert-lambert-to-latitude-and-logitude/58915/3 "2016-08-25T11:48:08Z")

</div>

haha  
Lambert enables to get another type of geographical coordinates based on coni map projection.  
Here is the wikipedia link to get all details: [https://en.wikipedia.org/wiki/Lambert\_conformal\_conic\_projection](https://en.wikipedia.org/wiki/Lambert_conformal_conic_projection)

My purpose is just to convert this reprsentation in latitude and longitude coordinates

---

<div class="post-metadata">

### Author: ![sen](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@sen](https://discuss.elastic.co/u/sen)
#### Post date: [August 26, 2016, 10:21am UTC](https://discuss.elastic.co/t/logstash-convert-lambert-to-latitude-and-logitude/58915/4 "2016-08-26T10:21:10Z")

</div>

I wrote my own plugin by using the ruby code indicated in my question and the following tutorial: [https://www.elastic.co/guide/en/logstash/current/\_how\_to\_write\_a\_logstash\_filter\_plugin.html](https://www.elastic.co/guide/en/logstash/current/_how_to_write_a_logstash_filter_plugin.html)

---

<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: [August 26, 2016, 10:24am UTC](https://discuss.elastic.co/t/logstash-convert-lambert-to-latitude-and-logitude/58915/5 "2016-08-26T10:24:09Z")

</div>

Well that's definitely one solution 😉  
Any plans to open source it?

---

<div class="post-metadata">

### Author: ![sen](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@sen](https://discuss.elastic.co/u/sen)
#### Post date: [August 31, 2016, 1:09pm UTC](https://discuss.elastic.co/t/logstash-convert-lambert-to-latitude-and-logitude/58915/6 "2016-08-31T13:09:50Z")

</div>

Yes, i will do in the end of the week !

---

<div class="post-metadata">

### Author: ![sen](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@sen](https://discuss.elastic.co/u/sen)
#### Post date: [September 4, 2016, 12:20pm UTC](https://discuss.elastic.co/t/logstash-convert-lambert-to-latitude-and-logitude/58915/7 "2016-09-04T12:20:11Z")

</div>

I have just one problem with my filter. Indeed, my filter works like this:  
convert =\> ["typeLambert", x, y]  
where:

- typelambert is the type of lambert (string)
- x is the lattitude in lamber (float type)
- y is the longitude in lambert (float type)

where I write, for instance, convert =\> ["LambertIIExtended", 2478517.33, 547536.68] , it works well !  
But, when I read a file or a kafka topic where I have parameters like below:  
{"lati":2478517.33, "longi":547536.68}  
{"lati":2699120.65, "longi":544959.56}  
{"lati":2149001.71, "longi":588529.14}  
It does not work when I write convert =\> ["LambertIIExtended", "%{[lati]}", "%{[longi]}"]

I printed the output results and ruby does not get the float value of my parameters lati and longi, it reads and prints them exactly like strings "%{[lati]}" and "%{[longi]}". Do you knwo how I could solve this ?

I put in Annexe my filter part.  
**My logstash filter part:**  
filter {  
lambert {  
convert =\> ["LambertIIExtended", "%{[lati]}", "%{[longi]}"] #it does work because  
#convert =\> ["LambertIIExtended", 2478517.33, 547536.68] #it works  
latitude =\> ["latnew"]  
longitude =\> ["longnew"]  
}  
}

PS: if you need my ruby code, I can provide it. (it is just a little bit long that's why I did not add here)

---

<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: [September 5, 2016, 1:38am UTC](https://discuss.elastic.co/t/logstash-convert-lambert-to-latitude-and-logitude/58915/8 "2016-09-05T01:38:44Z")

</div>

I don't think your field references are correct, have a look at [https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#logstash-config-field-references](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#logstash-config-field-references)

---

<div class="post-metadata">

### Author: ![sen](https://avatars.discourse-cdn.com/v4/letter/s/cc9497/32.png) [@sen](https://discuss.elastic.co/u/sen)
#### Post date: [September 5, 2016, 8:03am UTC](https://discuss.elastic.co/t/logstash-convert-lambert-to-latitude-and-logitude/58915/9 "2016-09-05T08:03:37Z")

</div>

Thanks for the link but I already tried to use like shown in the link: "%{lati}" or " %{[lati]} and it does not work !!!

i am really stuck and I don't know how to do

---

<div class="post-metadata">

### Author: ![wiibaa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wiibaa/32/44931_2.png) [@wiibaa](https://discuss.elastic.co/u/wiibaa)
#### Post date: [October 3, 2016, 10:37am UTC](https://discuss.elastic.co/t/logstash-convert-lambert-to-latitude-and-logitude/58915/10 "2016-10-03T10:37:50Z")

</div>

@sen, any chance to see your code already, hosted somewhere like github ?  
it would be easier to check how you are retrieving the event value,  
It is the responsibility of the plugin to fetch the needed data from the event with event.get() or event.sprintf() and is not done on your behalf internally

---

<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 6, 2017, 4:36am UTC](https://discuss.elastic.co/t/logstash-convert-lambert-to-latitude-and-logitude/58915/11 "2017-07-06T04:36:09Z")

</div>


