ArchGDAL Convexhull not return a polygon

Hello Everyone,

I am new to julia and currently using ArchGDAL. Currently, I want to compute a convex hull for a lot of points. When I using AG.convexhull, and save the result to a shapefile using GeoDataFrames. When I open the shapefile with QGIS, the shapefile is still the orignal points. The result should be a convexhull polygon (only one polygon).

Here is the code:

coords = zip(rand(10), rand(10))
points=AG.createpoint.(coords)
hull=AG.convexhull(points)
table = DataFrame(geom = hull)
GDF.write(“hull.shp”, table)

Also, does anyone know how to read shapefile(points) and compute convex hull for shapefile directly?

Any help on this? Thanks in advance!

You can do it with GMT

using GMT

pts = rand(10,2);                                         
c = convexhull(pts, gdataset=true);           # gdataset option is optional but here avoids unnecessary conversions      
gdalwrite(c, "lixo.shp")                              # Save it as a shape

# Confirm 
imshow(gmtread("lixo.shp"), plot=(data=pts, marker=:star))

1 Like