# Getting a surface from a list of points using geopandas or shapely

Given a set of points I would like to have the boundary given by the outtermost points of the set. For example: if I have 11 points, 10 being on the perimeter of a circle (each one at 2*pi/10 radians) and some in the center (or "inside" of the other set of points) corners of a given circle:

``````n_points_on_circle = 10
theta = np.linspace(0, 2 * np.pi, n_points_on_circle + 1, endpoint=True)
x = np.cos(theta)
y = np.sin(theta)

n_rand = 300
r_rand = .92 * np.sqrt(np.random.random(n_rand))
theta_rand =  2 * np.pi *np.random.random(n_rand)
x_rand = r_rand * np.cos(theta_rand)
y_rand = r_rand * np.sin(theta_rand)

plt.plot(x,y, marker='o')
plt.scatter(x_rand, y_rand, marker='o', c='r')
ax = plt.gca()
ax.set_aspect('equal')
``````

Returns the following image

And making a geodataframe with it:

``````all_y = np.concatenate([y, y_rand])
all_x = np.concatenate([x, x_rand])
gdf = gpd.GeoDataFrame(data=dict(lat=all_y, lon=all_x, geometry=gpd.points_from_xy(all_x, all_y)))
gdf.plot()
``````

we have the following:

So the question ends up being. Given a geodataframe like gdf, how can I recover the blue polygon shown in the first figure?

This seems so simple I can't believe I would need to work it out. I think there must be a method to do it automatically.

You can use `gdf.unary_union.convex_hull`.
`unary_union` makes a multipoint geometry from points, and `convex_hull` gives you the polygon you want to recover.