# Creating polygons based on point layer using QGIS

I have a point layer of residential coordinates which includes an attribute field indicating the most visited hospital for the people living at the coordinate. From these data, I want to create a polygon layer of "hospital areas" that groups neighboring coordinates with the same most visited hospital, with a bit of an outside buffer, as illustrated below. Ideally, I want the polygons to cover also "weird" coordinate pairs, i.e. any coordinates which are clearly geographically located within a larger cluster with the same most visited hospital, but which they themselves have a deviating most visited hospital. Please see the example of Hospital B in the middle of the Hospital A cluster in my illustration.

How do I do this? The real data covers many thousand coordinate pairs and a total of 150 different hospitals.

• The odd thing to me is how can HospitalB be in the center of HospitalA? :) Jan 4, 2021 at 21:09
• Each point is a residential location and the name of the hospital indicated is the most visited hospital by individuals residing on the point. Sorry if that was unclear :) Jan 4, 2021 at 21:15
• No. It was pretty clear. But I just misread. :( Jan 4, 2021 at 21:18
• Could you add an example image showing what you exactly expect / what kind of cluster? Should/Shouldn't polygons intersect? Jan 4, 2021 at 21:21

My first idea would be to create the convex hull of the grouped points and than apply a buffer to the resulting polygons. But you also want to include "weird" locations: did I understand you right that your screenshot does not represent the solution as you want it. You rather want Hospital B inside the polygon of Hospitals to be located like an island in an own polygon?

Than I would start to create Voronoi polygons and than dissolve them based on attributes.

This is how the solution with the convex hull looks like - I used `Menu Processing / Toolbox / Minimum bounding geometry`, set the points as input layer, the name (A,B,C) as field and as geometry type: Convex hull.

And this is how the solution with the Voronoi polygons looks: first step, `Menu Processing / Toolbox / Voronoi polygons`, second step `Menu Processing / Toolbox / Dissolve` and set `Dissolve field(s)` to `name` field, see:

If you than apply a negative buffer, you get "insular" polygons (that do not touch each other, as on your screenshot). You can see this on the next screenshot:

Polygon B has a hole where hospital A is locatated - you could use `delete ring` from the toolbox to get rid of that: To get rid of the overlapping small polygon A, run `Menu Vector / Geometry tools / Multipart to singleparts`. Than sort the attribute table of the resulting layer after the name and create a new field with field calculator to create the area with `\$area`. Now you see that the smaller one of the two A-polygons can be deleted:

And this is how the result looks like:

• Thank you @babel, that sounds like a great start. I want the Hospital B nested inside the Hospital A polygon to be belong to the Hospital A polygon as shown in the picture. Jan 4, 2021 at 21:11