# How can I create (or get closest to create) a convex hull with geo aggregation

**URL:** <https://discuss.elastic.co/t/how-can-i-create-or-get-closest-to-create-a-convex-hull-with-geo-aggregation/102924>\
**Category:** Elasticsearch\
**Created:** [October 5, 2017, 11:52pm UTC](https://discuss.elastic.co/t/how-can-i-create-or-get-closest-to-create-a-convex-hull-with-geo-aggregation/102924 "2017-10-05T23:52:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maethorin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maethorin/32/22825_2.png) [@Maethorin](https://discuss.elastic.co/u/Maethorin)\
**Post date:** [October 5, 2017, 11:52pm UTC](https://discuss.elastic.co/t/how-can-i-create-or-get-closest-to-create-a-convex-hull-with-geo-aggregation/102924/1 "2017-10-05T23:52:47Z")

</div>

Hello fellow searchers!

I have an index with some millions geographic coordinates, each one representing agricultural soil information. I have 2-3 millions hectares of data in a resolution of 25 points per hectare.

With each point (its a GeoPoint type), I have some keywords to help me aggregate these data. I already have queries to extract a lot of information with this. I can get bbox, centroids and other things from this aggregated cloud points.

What I need now is extract the polygon for a query result. I could do this in Python/GDAL using convex hull, but for each geographic coordinate I have several information and the data volume could be too high to load over http to my API. I can make filters, but I risk to get a wrong boundary because I could not have sure about how many points its enough to define the boundary.

The better way I could think is creating this Convex Hull with Elasticsearch as a result of an aggregation, but I don't know enough of Elasticsearch to know if it is possible and I don't know how to do this. There's a way to write a custom aggregation for it? Something in Python or Java that I can install in my server and call it from my queries?

There are already something like this?

Ty All!

---

<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:** [November 2, 2017, 11:53pm UTC](https://discuss.elastic.co/t/how-can-i-create-or-get-closest-to-create-a-convex-hull-with-geo-aggregation/102924/2 "2017-11-02T23:53:01Z")

</div>

Closed on November 2, 2017, 11:53pm UTC

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