def _get_boundary(self, tolerance=0.2): from shapely.geometry import MultiPoint xys = list(zip(self.x.flatten(), self.y.flatten())) polygon = MultiPoint(xys).convex_hull polygon = polygon.simplify(tolerance=tolerance) return polygon