Foncho
Foncho

Reputation: 15

Create geojson polygon from point feature collection

I have this feature collection with a lot of points that form a shape:

enter image description here

I need to create a polygon feature collection with this shape, I tried using the shapely multipoint.convex_hull method but the results are way too different from the original shape, which tools or methods can I use to create a polygon from these points?

The polygon I want to generate would looks sort of like this: (don't mind the coordinates, I'll adjust that later):

enter image description here

The inner part is not important for now, I just need the outline

I'm extracting the points from a point cloud file:

enter image description here

Upvotes: 0

Views: 45

Answers (1)

Bera
Bera

Reputation: 1949

Try concave_hull.

You will have to tweak the ratio parameter (0-1). With my points I get the best result with 0.086.

import geopandas as gpd
df = gpd.read_file(r"C:\Users\bera\Desktop\gistest\building_points.shp")
ax = df.plot(figsize=(10,10), color="blue", zorder=1, markersize=4)

hull = df.dissolve().concave_hull(ratio=0.086) #Dissolve by some unique id if you have multiple buildings
hull.plot(ax=ax, zorder=0, color="orange")

enter image description here

Upvotes: 0

Related Questions