# Replace LAT and LON values

**URL:** <https://discuss.elastic.co/t/replace-lat-and-lon-values/201089>\
**Category:** Logstash\
**Created:** [September 25, 2019, 6:33pm UTC](https://discuss.elastic.co/t/replace-lat-and-lon-values/201089 "2019-09-25T18:33:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SirJune](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sirjune/32/55205_2.png) [@SirJune](https://discuss.elastic.co/u/SirJune)\
**Post date:** [September 25, 2019, 6:33pm UTC](https://discuss.elastic.co/t/replace-lat-and-lon-values/201089/1 "2019-09-25T18:33:02Z")

</div>

my goal is to not plot the "dot" down to spcific state or city, just country.  
Sample data:

```
"geoip" => {
          "latitude" => 44.6628,
          "location" => {
        "lon" => -93.1539,
        "lat" => 44.6628
    }

```

I want to replace with lon = -98.35 and lat = 39.50

I tried the following:

if [geoip][country\_name] == "United States" {  
mutate { replace =\> ["[geoip][latitude][lat]", 39.50 ] }  
mutate { replace =\> ["[geoip][longitude][lon]",-98.35 ] }

```
mutate {
  convert => { "[geoip][longitude][lat]" => "float" }
  convert => { "[geoip][longitude][lon]" => "float" }
}

```

}

last error/exception i got is : [2019-09-25T13:04:45,361][WARN][logstash.filters.mutate] Exception caught while applying mutate filter {:exception=\>"Could not set field 'lat' on object '41.2709' to value '39.50'.This is probably due to trying to set a field like [foo][bar] = someValuewhen [foo] is not either a map or a string"}

the same error for "lon"

how do i replace geoip.location with fix coordinates?

thanks,  
Sirjune

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [September 25, 2019, 6:37pm UTC](https://discuss.elastic.co/t/replace-lat-and-lon-values/201089/2 "2019-09-25T18:37:48Z")

</div>

> [@SirJune](#):
>
> mutate { replace =\> ["[geoip][latitude][lat]", 39.50 ] }  
> mutate { replace =\> ["[geoip][longitude][lon]",-98.35 ] }

[geoip][latitude] is a string, not an object, so it cannot have a [lat] field.

[geoip][longitude] does not exist. Did you mean [geoip][location]?

---

<div class="post-metadata">

**Author:** ![SirJune](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sirjune/32/55205_2.png) [@SirJune](https://discuss.elastic.co/u/SirJune)\
**Post date:** [September 25, 2019, 7:02pm UTC](https://discuss.elastic.co/t/replace-lat-and-lon-values/201089/3 "2019-09-25T19:02:33Z")

</div>

@Badger, grr! my bad! yah, i mean "geoip.location". Tired eyes 🙂

should have been:  
mutate { replace =\> ["[geoip][location][lat]", 39.50 ] }  
mutate { replace =\> ["[geoip][location][lon]",-98.35 ] }

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [September 25, 2019, 7:25pm UTC](https://discuss.elastic.co/t/replace-lat-and-lon-values/201089/4 "2019-09-25T19:25:16Z")

</div>

Does that mean the problem is fixed? Was the typo in the question or in the configuration?

---

<div class="post-metadata">

**Author:** ![SirJune](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sirjune/32/55205_2.png) [@SirJune](https://discuss.elastic.co/u/SirJune)\
**Post date:** [September 25, 2019, 7:52pm UTC](https://discuss.elastic.co/t/replace-lat-and-lon-values/201089/5 "2019-09-25T19:52:02Z")

</div>

@Badger, Yes the typo was the problem. And a little bit in the coordinates (minutes to decimal)

Thanks much again!  
if [geoip][country\_name] == "United States" {  
mutate { replace =\> ["[geoip][location][lat]", 39.833 ] }  
mutate { replace =\> ["[geoip][location][lon]",-98.583 ] }  
mutate {  
convert =\> { "[geoip][location][lat]" =\> "float" }  
convert =\> { "[geoip][location][lon]" =\> "float" }  
}

---

<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:** [October 23, 2019, 7:52pm UTC](https://discuss.elastic.co/t/replace-lat-and-lon-values/201089/6 "2019-10-23T19:52:08Z")

</div>

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