# How to generate a pie chart from geo\_points within a geo\_shape in ELK?

**URL:** <https://discuss.elastic.co/t/how-to-generate-a-pie-chart-from-geo-points-within-a-geo-shape-in-elk/258312>\
**Category:** Kibana\
**Created:** [December 10, 2020, 5:35pm UTC](https://discuss.elastic.co/t/how-to-generate-a-pie-chart-from-geo-points-within-a-geo-shape-in-elk/258312 "2020-12-10T17:35:42Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![MichaelLevy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michaellevy/32/80620_2.png) [@MichaelLevy](https://discuss.elastic.co/u/MichaelLevy)\
**Post date:** [December 10, 2020, 5:35pm UTC](https://discuss.elastic.co/t/how-to-generate-a-pie-chart-from-geo-points-within-a-geo-shape-in-elk/258312/1 "2020-12-10T17:35:42Z")

</div>

Hello everyone! I have created a map by importing GEOJSON data in KIBANA.

The data is indexed as geo\_shape and it contains the World's territorial waters area. It represents a layer in my map. I have then added another layer, always using GEOJSON, containing geo\_points representing the gps data of a yacht charter:

 ![BE0v5](https://us1.discourse-cdn.com/elastic/original/3X/e/3/e3f16110354dfc212679432ac756fc360eb9cfa6.jpeg)

Now, in my dashboard, I would like to show a pie chart, indicating the percentage of time spent by the yacht during this charter outside of the territorial waters, but I am unable to understand how to do that.

You can see the GEOJSON file here: [Charter Trip GeoJSON](http://84.33.95.3:81/tatiana_charter.geojson)

I generated it from a CSV file.

Here you can see the territorial waters [Territorial Waters GeoJSON](http://84.33.95.3:81/eez_12nm.json)[http://84.33.95.3:81/eez\_12nm.json](http://84.33.95.3:81/eez_12nm.json)

I was thinking to use the geo\_shape created by the territorial waters as boundaries, then I would add a layer for each charter trip and I need to output the percentage of time spent outside of the boundaries for VAT calculation purposes, I do not really need to know the yacht's name, but rather how much time a single boat has spent outside of territorial waters (in percentage).

Any help would be really really appreciated!

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [December 14, 2020, 4:23pm UTC](https://discuss.elastic.co/t/how-to-generate-a-pie-chart-from-geo-points-within-a-geo-shape-in-elk/258312/2 "2020-12-14T16:23:11Z")

</div>

You can use [enrich](https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-processor.html) ingest processor to enrich your point locations with field indicating whether the points are outside of territorial waters ([https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-match-enrich-policy-type.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-match-enrich-policy-type.html)). Then, you can use this new field to create the desired pie chart.

---

<div class="post-metadata">

**Author:** ![MichaelLevy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michaellevy/32/80620_2.png) [@MichaelLevy](https://discuss.elastic.co/u/MichaelLevy)\
**Post date:** [December 15, 2020, 8:41am UTC](https://discuss.elastic.co/t/how-to-generate-a-pie-chart-from-geo-points-within-a-geo-shape-in-elk/258312/3 "2020-12-15T08:41:27Z")

</div>

Thanks @Nathan_Reese! Will give it a try later on today and post the outcome here!

---

<div class="post-metadata">

**Author:** ![MichaelLevy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michaellevy/32/80620_2.png) [@MichaelLevy](https://discuss.elastic.co/u/MichaelLevy)\
**Post date:** [December 22, 2020, 5:21pm UTC](https://discuss.elastic.co/t/how-to-generate-a-pie-chart-from-geo-points-within-a-geo-shape-in-elk/258312/5 "2020-12-22T17:21:31Z")

</div>

Hello again everyone! So, I went a bit further, but not so much unfortunately, and I am still stuck.

I managed to ingest AIS positions as geo points from API requests using Logstash pipelines and mutate filters, I get the yachts positions on my map, which has a layer containing the geo shapes of the World's territorial waters, but I am still unable to understand how to generate charts based upon the time spent by a vessel outside (or inside) the territorial waters.

I have learned a lot on how to generate geo points etc., but I am now really desperate to find a solution on how to have a percentage of time spent by the yachts outside of the geo shapes...

I tried to use @Nathan_Reese solution, but with no chance, where am I mistaking?

Thanks!

---

<div class="post-metadata">

**Author:** ![MichaelLevy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michaellevy/32/80620_2.png) [@MichaelLevy](https://discuss.elastic.co/u/MichaelLevy)\
**Post date:** [December 22, 2020, 6:20pm UTC](https://discuss.elastic.co/t/how-to-generate-a-pie-chart-from-geo-points-within-a-geo-shape-in-elk/258312/6 "2020-12-22T18:20:50Z")

</div>

I am reading (but not understanding...), this:

> **[Enrich processor | Elasticsearch Reference \[7.10\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/enrich-processor.html)**

---

<div class="post-metadata">

**Author:** ![MichaelLevy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michaellevy/32/80620_2.png) [@MichaelLevy](https://discuss.elastic.co/u/MichaelLevy)\
**Post date:** [December 23, 2020, 10:07am UTC](https://discuss.elastic.co/t/how-to-generate-a-pie-chart-from-geo-points-within-a-geo-shape-in-elk/258312/7 "2020-12-23T10:07:24Z")

</div>

I now created and executed the Enrich policy:

```auto
    PUT /_enrich/policy/within_tw_policy
    
      "geo_match": {
        "indices": "territorial-waters-def",
        "match_field": "coordinates",
        "enrich_fields": ["coordinates", "location"]
      }
    }

POST /_enrich/policy/within_tw_policy/_execute

```

Then I added the Enrich processor to the ingest pipeline "queen-elizabeth-pipeline" that contains the geo points (the index "territorial-waters-def" contains the geo shapes that define the territorial waters). I just don't get what I need to to next...

---

<div class="post-metadata">

**Author:** ![MichaelLevy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michaellevy/32/80620_2.png) [@MichaelLevy](https://discuss.elastic.co/u/MichaelLevy)\
**Post date:** [December 23, 2020, 10:33am UTC](https://discuss.elastic.co/t/how-to-generate-a-pie-chart-from-geo-points-within-a-geo-shape-in-elk/258312/8 "2020-12-23T10:33:07Z")

</div>

I am really lost... How to index data through a pipeline? I removed and re-created the index "queen-elizabeth" and the pipeline I created was overwritten....

---

<div class="post-metadata">

**Author:** ![MichaelLevy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/michaellevy/32/80620_2.png) [@MichaelLevy](https://discuss.elastic.co/u/MichaelLevy)\
**Post date:** [December 23, 2020, 3:33pm UTC](https://discuss.elastic.co/t/how-to-generate-a-pie-chart-from-geo-points-within-a-geo-shape-in-elk/258312/9 "2020-12-23T15:33:54Z")

</div>

I am really lost, I do not understand how I can do that, I tried everything I could find, but I am getting nowhere

---

<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:** [January 20, 2021, 3:33pm UTC](https://discuss.elastic.co/t/how-to-generate-a-pie-chart-from-geo-points-within-a-geo-shape-in-elk/258312/10 "2021-01-20T15:33:57Z")

</div>

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