SpatialHackathon / SpaceHack2023

MIT No Attribution
14 stars 3 forks source link

Method MERINGUE #316

Open peicai opened 1 month ago

peicai commented 1 month ago

Got an error while testing:

Error in geometry::delaunayn(pos, output.options = FALSE) :
Received error code 1 from qhull. Qhull error:
QH6239 Qhull precision error: Initial simplex is cocircular or cospherical.  Use option 'Qz' for the Delaunay triangulation or Voronoi diagram of cocircular/cospherical points.  Option 'Qz' adds a point "at infinity".  Use option 'Qs' to search all points for the initial simplex.

While executing:  | qhull d Qbb T0 Qt Qc Qx
Options selected for Qhull 2015.2.r 2016/01/18:
run-id 1924240702  delaunay  Qbbound-last  Qtriangulate  Qcoplanar-keep
Qxact-merge  _zero-centrum  Qinterior-keep  Q3-no-merge-vertices-dim-high
Pgood  _max-width 9.3e+03  Error-roundoff 5.8e-11  _one-merge 1.1e-09
Visible-distance 3.5e-10  U-coplanar-distance 3.5e-10  Width-outside 7e-10
_wide-facet 2.1e-09
Calls: getSpatialNeighbors -> <Anonymous>
Execution halted

Source code copied from MERINGUE GitHub:

getSpatialNeighbors <- function(pos, filterDist = NA, binary=TRUE, verbose=FALSE) {
  if(is.null(rownames(pos))) {
    rownames(pos) <- seq_len(nrow(pos))
  }

  ## shift duplicates slightly or else duplicates are lost
  if(sum(duplicated(pos))>0) {
    if(verbose) { message(paste0("Duplicated points found: ", sum(duplicated(pos)), "...")) }
    pos[duplicated(pos),] <- pos[duplicated(pos),] + 1e-6
  }

  ## delaunay triangulation
  tc <- geometry::delaunayn(pos, output.options=FALSE)
...

Possible reasons:

"Raised when Qhull encounters an error condition, such as geometrical degeneracy when options to resolve are not enabled" [source].

shdam commented 1 month ago

Just a guess, but could it be because output.options=FALSE is an invalid setting for geometry::delaunayn and should be NULL?

https://www.rdocumentation.org/packages/geometry/versions/0.4.7/topics/delaunayn

Jieran-S commented 2 days ago

Would it be due to the identical z-axis? I remember encountering similar problem before and can be resolved by removing the identical z-axis