Issue with ConvexHullMesh function
Issue with ConvexHullMesh function
List of points
List of points
{ x=easting | y=northing | z=elevation }.
In[]:=
xyz=;
Show number of points in the dataset.
In[]:=
xyz//Length
Out[]=
56752
Take just the { easting | northing } values.
In[]:=
xy=xyz[[All,;;2]]
Out[]=
Use Jon McLoone’s Resource function to get a non-convex hull mesh
Use Jon McLoone’s Resource function to get a non-convex hull mesh
This works fine.
In[]:=
Show[resourceFunctionBM=BoundaryMesh[ResourceFunction["NonConvexHullMesh"][xy,90]],ListPlot[xyz[[All,1;;2]],AspectRatio->Automatic,FrameLabel->{"Easting","Northing"},PlotRange->All],Frame->True]
Out[]=
Use system function to get the convex hull mesh
Use system function to get the convex hull mesh
In[]:=
convexHull=ConvexHullMesh[xy,Frame->True]
Out[]=
Use system function to get a concave hull mesh
Use system function to get a concave hull mesh
This fails (even with the alpha value set to Infinity)...
This fails (even with the alpha value set to Infinity)...
In[]:=
ConcaveHullMesh[xy,Infinity]
Out[]=
A concave hull mesh is retuned if the function is fed a sub-sample of the point dataset
A concave hull mesh is retuned if the function is fed a sub-sample of the point dataset
Whilst this might provide a clue as to what’s causing the issue, it isn’t a satisfactory solution.
In[]:=
ConcaveHullMesh[RandomChoice[xy,10000],200,Frame->True]
Out[]=
A solution...
A solution...
It appears that the modestly large coordinate values, possibly combined with the large number of points in the dataset, causes the function to fail. Shifting the mesh seems to resolve the issue. Here, I’ve shifted all the point coordinates such that they are centred around the centroid of the point set’s convex hull mesh region.
In[]:=
xyCentroid=RegionCentroid[convexHull]
Out[]=
{612162.,189605.}
In[]:=
concaveHullMesh=ConcaveHullMesh[#-xyCentroid&/@xy,45,Frame->True]
Out[]=
In[]:=
BoundaryMesh[concaveHullMesh,Frame->True,MeshCellStyle->{1->Directive[{Red,Thick}],2->None}]
Out[]=