![]() Takes the convex hull verticies (an array of indicies) and To the below function which writes out the xy positions of hull_indices from xy_file (in the format I required): def write_convex_hull_xy ( xy_file, hull_indices, opath, file_name ): ''' ![]() The hull vertex indices (hull_indices) can then be passed in with the main xy point file (xy_file) (along with an output path (opath) and output file name (file_name) Hull_indicies - which more precisely are the “ndices of points forming the simplical facets of the convex hull” - will look something like this: array (, dtype = int32 ) vertices print "Found %d hull points" % len ( hull_indices ) print "Hull indicies calculated and now being returned." return xy_file, hull_indices ConvexHull ( xy_file, qhull_options = "Qt" ) hull_indices = hull. exit ( "File for convex hull calculation doesn't exist" ) print "Calculating hull points." hull = spatial. loadtxt ( input_xy_file, usecols = ( 0, 1 )) else : sys. isfile ( input_xy_file ): print "Loading file." xy_file = np. ![]() Returning the indicies of the convex hull points This is all integrated into a single function: import os import sys import numpy as np from scipy import spatial def xy_convex_hull ( input_xy_file ): '''Ĭalculates the convex hull of a given xy data set Pulling out the “vertices” from the spatial.ConvexHull object - this gives the indicies of the convex hull points within the original xy input file: hull = spatial. This is predominantly facilitated using scipy spatial’s ConvexHull function.įor my application I required the hull points to be printed out into a txt/csv in order of position (i.e. A first approach was to calculate the convex hull of the points. Working with LiDAR point data it was necessary for me to polygonize the point cloud extent.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |