Search code examples
rubyrgeo

RGeo convex hull of list of points


RGeo has convex hull method available, but no documentation at all in this matter.

Given set of Points, how to I find their convex hull?


Solution

  • Good question. Turns out there is a geometry type called "MultiPoint" that works for this. I made a simple example to test it out and it appears to work well.

    f = RGeo::Geos.factory(:srid => 3361, :buffer_resolution => 8) #my typical local rectilinear projection factory with my default settings.
    coords = [[1,1], [2,2], [1,3]]
    points = []
    coords.each {|x,y| points << f.point(x,y)}
    

    points

    f.multi_point(points).convex_hull
    

    looks good to me