# How can I plot Google map with Long and Lat?

**URL:** https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647
**Category:** Kibana
**Created:** [July 3, 2017, 2:16pm UTC](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647 "2017-07-03T14:16:30Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![patil-akshay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/patil-akshay/32/15295_2.png) [@patil-akshay](https://discuss.elastic.co/u/patil-akshay)
#### Post date: [July 3, 2017, 2:16pm UTC](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647/1 "2017-07-03T14:16:30Z")

</div>

I have two columns in my data I am loading data directly using bulk API(without logstash) I want to plot the map how can I plot it or else what is format of GEOIP which kibana accepts by default how to convert lat long into geoip.

---

<div class="post-metadata">

### Author: ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)
#### Post date: [July 3, 2017, 3:48pm UTC](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647/2 "2017-07-03T15:48:22Z")

</div>

Hi Akshay,

Could you please share a snippet of what your data looks like? It should look something like this:

```auto
{
  "lat": 44.529845,
  "lon": -122.9295336
}

```

Assuming that the name of the field is "geo.coordinates", here is how you can configure a Coordinate Map visualization to aggregate this data:

![](https://us1.discourse-cdn.com/elastic/original/3X/a/5/a56cd99ca67dea9668a68198b49441c1e79fd018.png)

Does this help?

Thanks,  
CJ

---

<div class="post-metadata">

### Author: ![patil-akshay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/patil-akshay/32/15295_2.png) [@patil-akshay](https://discuss.elastic.co/u/patil-akshay)
#### Post date: [July 3, 2017, 4:01pm UTC](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647/3 "2017-07-03T16:01:36Z")

</div>

I have Lat long in two different columns. What should be the value of geo.coordinates column?

---

<div class="post-metadata">

### Author: ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)
#### Post date: [July 3, 2017, 4:04pm UTC](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647/4 "2017-07-03T16:04:37Z")

</div>

You'll need to create a single column that contains an object with "lat" and "lon" properties, like in the example I posted above:

```auto
{
  "lat": 44.529845,
  "lon": -122.9295336
}

```

Can you share an example of your data?

Thanks,  
CJ

---

<div class="post-metadata">

### Author: ![patil-akshay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/patil-akshay/32/15295_2.png) [@patil-akshay](https://discuss.elastic.co/u/patil-akshay)
#### Post date: [July 3, 2017, 4:07pm UTC](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647/5 "2017-07-03T16:07:39Z")

</div>

Data

![](https://us1.discourse-cdn.com/elastic/original/3X/8/9/89b032dc3bb72d9b73a369d40318ada625102692.PNG)

Kibana

![](https://us1.discourse-cdn.com/elastic/original/3X/3/6/36fb8c58f5bc8d3218db99b0a3a235257f38ad56.PNG)

---

<div class="post-metadata">

### Author: ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)
#### Post date: [July 3, 2017, 4:20pm UTC](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647/6 "2017-07-03T16:20:08Z")

</div>

Hi Akshay, the "geoip.location" field is just an example. The data set I'm using has that field, but it doesn't look like your data set does. You'll have to create a field that consists of an object with the "latitude" and "longitude" fields from your data set. Does this make sense?

CJ

---

<div class="post-metadata">

### Author: ![patil-akshay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/patil-akshay/32/15295_2.png) [@patil-akshay](https://discuss.elastic.co/u/patil-akshay)
#### Post date: [July 3, 2017, 4:21pm UTC](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647/7 "2017-07-03T16:21:27Z")

</div>

How to create that field which contains object of lat an long?

---

<div class="post-metadata">

### Author: ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)
#### Post date: [July 3, 2017, 5:22pm UTC](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647/8 "2017-07-03T17:22:01Z")

</div>

Can you try using Logstash to transform your data? Take a look at the `mutate` plugin filter, specifically configured with `add_field`: [https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-add\_field](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-add_field).

You'll want to end up with something like this:

```auto
filter {
  mutate {
    rename => {
      'latitude' => '[geo][lat]'
      'longitude' => '[geo][lon]'
    }
  }
}

```

or:

```auto
filter {
  mutate {
    rename => {
      'latitude' => '[geo][0]'
      'longitude' => '[geo][1]'
    }
  }
}

```

For some more context, what we're trying to do is wrangle some of your data to create a new field which conforms to the `geo_point` datatype ([https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html)).

CJ

---

<div class="post-metadata">

### Author: ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)
#### Post date: [July 3, 2017, 5:39pm UTC](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647/9 "2017-07-03T17:39:12Z")

</div>

Sorry Akshay, I just found out that it will actually be a two-step process in Logstash. This is because our field references always convert the values to strings. So the configuration will look like this:

```auto
  mutate { add_field => { 'geo' => ['%{[latitude]}', '%{[longitude}'] } }
  mutate { convert => {
      '[geo][0]' => 'float'
      '[geo][1]' => 'float'
    }
  }

```

This first creates the `geo` field with the values from your `latitude` and `longitude` fields, and then converts them from strings to floats.

Does this help?

CJ

---

<div class="post-metadata">

### Author: ![patil-akshay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/patil-akshay/32/15295_2.png) [@patil-akshay](https://discuss.elastic.co/u/patil-akshay)
#### Post date: [July 4, 2017, 5:18am UTC](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647/10 "2017-07-04T05:18:14Z")

</div>

Hi CJ  
Actually, I am inserting data through bulk API using curl commands is there any way I can add this geo field through curl command?

---

<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 4, 2017, 5:34am UTC](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647/11 "2017-07-04T05:34:57Z")

</div>

No, you need something to "join" the lat and lon fields.

---

<div class="post-metadata">

### Author: ![patil-akshay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/patil-akshay/32/15295_2.png) [@patil-akshay](https://discuss.elastic.co/u/patil-akshay)
#### Post date: [July 4, 2017, 7:52am UTC](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647/12 "2017-07-04T07:52:45Z")

</div>

suppose if I create on field called geoip.location which has value "lat,long"

or

Kibana by default takes to field geoip.lonitude and geoip.latitude should I rename my column name from latitude to geoip.latitude and longitude to geoip.lonitude

---

<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 4, 2017, 7:53am UTC](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647/13 "2017-07-04T07:53:34Z")

</div>

You need to do the first one.

---

<div class="post-metadata">

### Author: ![patil-akshay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/patil-akshay/32/15295_2.png) [@patil-akshay](https://discuss.elastic.co/u/patil-akshay)
#### Post date: [July 4, 2017, 7:55am UTC](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647/14 "2017-07-04T07:55:19Z")

</div>

why not second? what should be the datatype of geoip.location string? or something else?

---

<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 4, 2017, 7:56am UTC](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647/15 "2017-07-04T07:56:44Z")

</div>

Because they are still individual fields, it needs to be in this format - [https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html)

---

<div class="post-metadata">

### Author: ![patil-akshay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/patil-akshay/32/15295_2.png) [@patil-akshay](https://discuss.elastic.co/u/patil-akshay)
#### Post date: [July 4, 2017, 7:57am UTC](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647/16 "2017-07-04T07:57:35Z")

</div>

String is fine right according to your link?

---

<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 4, 2017, 7:58am UTC](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647/17 "2017-07-04T07:58:19Z")

</div>

Yes;

> Geo-point expressed as **a string with the format: "lat,lon".**

---

<div class="post-metadata">

### Author: ![patil-akshay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/patil-akshay/32/15295_2.png) [@patil-akshay](https://discuss.elastic.co/u/patil-akshay)
#### Post date: [July 4, 2017, 7:59am UTC](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647/18 "2017-07-04T07:59:03Z")

</div>

field name must be geoip.location right ?

---

<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 4, 2017, 8:00am UTC](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647/19 "2017-07-04T08:00:14Z")

</div>

You can name it whatever you want. Logstash just uses `geoip.location` because it has a template it uses that defines that field as a geopoint. If you rename it you need a similar template or mapping.

[https://www.elastic.co/blog/geoip-in-the-elastic-stack](https://www.elastic.co/blog/geoip-in-the-elastic-stack) may be worth reading.

---

<div class="post-metadata">

### Author: ![patil-akshay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/patil-akshay/32/15295_2.png) [@patil-akshay](https://discuss.elastic.co/u/patil-akshay)
#### Post date: [July 4, 2017, 8:02am UTC](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647/20 "2017-07-04T08:02:38Z")

</div>

I am loading json data through curl command using bulk API then geoip.location should work right?

[Next page](https://discuss.elastic.co/t/how-can-i-plot-google-map-with-long-and-lat/91647.md?page=2)
