X and Y coordinates to latitude and longitude

Hi,
We have lots of locations with x,y coordinates but Logstash need lat, long values.
Could you please show how to convert from one to the other in a .config file.
Thanks
Roy

Can you post some of the data you have and the expected outcome?

Hi,
The values in the document are of the form:
"x": 533209,
"y": 243518,

I would like to turn it to a geo location to map as a heat map.
Thanks

You need to create a geopoint object field with your lat and long.
Give a read on this short documentation, it will help you on building your config.
https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html

> {
>   "text": "Geo-point as an object",
>   "location": { 
>     "lat": 41.12,
>     "lon": -71.34
>   }
> }

I'd get the fields, extract the values without the strings, and put them together in a new geopoint field. Something like this:

mutate {
  add_field => [ "[geoip][location]", "%{longitude}" ]
  add_field => [ "[geoip][location]", "%{latitude}" ]
}

Your outcome must be a field with the two coordinates together so Kibana can pick it up and build the points on the map for you.

1 Like

Hi,
Many thanks for your reply. It helped me.
What I was looking for is how to convert x,y coordinates to lat, lon. I found this article on the web. WSG84 to lat, lon
I do not know the accuracy yet, but hope it will help somebody else.
Kindest regards,

1 Like

Hi,
Need a bit more help. Logstash 6:

I have lat, lon now, and need to create a [location][lat] & [location][lon] geo_point.
The following is in the filter { mutate section
convert => { "LAT" => "float" }
convert => { "LON" => "float" }
add_field => { "[location][lat]" => "" }
add_field => { "[location][lon]" => "" }
copy => { "LAT" => "[location][lat]" }
copy => { "LON" => "[location][lon]" }
convert => { "[location][lat]" => "float"}
convert => { "[location][lon]" => "float"}

but I get
"location": {
"lat": "",
"lon": ""
},
Thank you in advance.

Can you edit the post and put your code in a preformatted text block using the button </> in the editor here?

I have a config that looks similar to the code below. After you have the coordinates in the appropriate fields, you need to reference them by using %{field_name}

# A geoip location field will be created with your 2 coordinates.
    mutate {
      add_field => [ "[geoip][location]", "%{longitude}" ]
      add_field => [ "[geoip][location]", "%{latitude}" ]
    }

# If the geoip location field is not in float type yet, you can finally convert it:
    mutate {
      convert => [ "[geoip][location]", "float" ]
    }

As an example, you will get this result:

{
                 "geoip" => {
                    "location" => [
                      [0] 144.36672,
                      [1] 43.011598
                    ]
                 },
              "latitude"        => "43.011598",
             "longitude"      => "144.36672",
            "@timestamp" => 2018-01-05T09:47:40.719Z,
              "@version"     => "1"
}

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