# Convex hull

Hi, I’d be interested in calculating, and then displaying on my life map, the convex hull of all my walks that link up around my home town. This would be a visual indicator of my ‘territory’. There are easily available algorithms to do this. I’d say that the only rule needed is that the walks join up to be included. Most people will have several convex hulls as they will typically walk in several localities.

I know all of these words separately.

This is the first time I’ve heard the term convex hull, and Wikipedia wasn’t helpful in teaching me (probably more a limitation on my available time of rabbit-holing through all the links).

Are you talking about places like this area around the water where I have many activities?

1 Like

New to me to. So I took a Google. This kinda makes sense:
[

### Convex hull

[image]
Wikipedia
https://en.wikipedia.org › wiki › Convex_hull
](Convex hull - Wikipedia)

The convex hull of a simple polygon encloses the given polygon and is partitioned by it into regions, one of which is the polygon itself. The other regions, …

Barging in because there’s finally somewhere where I can be like “MATHEMATICIAN TO THE RESCUE”. You can think of a convex hull as the smallest saran wrap around a set of points (or stuff) that doesn’t have any dents or divots in it. In the image, the leftmost shape is the convex hull of the points, the other two have ‘dents’

But Chris is right - basically any programming language will have a function where you give it a list of points and it will spit back the convex hull

4 Likes

Hell yeah! There are probably a few threads in this forum where mathematicians like you would be helpful.

That imagery helps show what it is and isn’t, which is useful.

It’s not built in to languages that are available to me (rather, available via third-party packages), but it is available in PostgreSQL via ST_ConvexHull from PostGIS. I like its description, as well:

One can think of the convex hull as the geometry obtained by wrapping a rubber band around a set of geometries.

I took a minute to play around with my own data locally, and it works well (and fast). I don’t see the utility of this, yet. I don’t understand what it adds to the existing LifeMap view, especially if viewing your LifeMap in the context of the city.
I’m probably missing some other aspect of the equation that results in a convex hull that’s meaningfully different from the city border itself. I don’t yet understand the question that this answers.

Chris does mention this, but I’m unsure what he means by “join up”:

I’d say that the only rule needed is that the walks join up to be included.

I believe he only wants to consider runs that are connected to eachother.

For example, for my heatmap in Belgium

You would consider the activities making up the interconnected blob spanning the country, but you would not consider those specks near the Maastricht label and other loose activities. Finding that interconnected blob might be more expensive computing time wise?

yeah I should have been more specific than for any language there’s probably a package out there with an implementation

Hrm, yeah, probably. Especially given that many activities will look interconnected at certain zooms, but really aren’t. There may be a way to query “activities within the city border that are within some distance of each other” or maybe the idea really is strictly interconnecting activities, which would likely reduce eligible data quite a bit.

I probably won’t dive into figuring that query out until after I get a good sense of what question this is answering. I don’t understand the “why” behind this, which pretty much guarantees I’ll build the wrong thing.