Given a set of coordinates, How do we find the boundary coordinates.
set of coordinates <== Figure 1
Given the coordinates in the above set, How can I get the coordinates on the red boundary. Boundary is the polygon which is formed by the input coordinates for vertices, in such a way that it maximizes the area.

I am working on an app which searches properties within 'x' miles of a city. What I have is:

  1. Coordinates of all the properties.
  2. A set of coordinates for each city (I have one coordinate for each zip. And since most cities have more than one zip, Every city has a set of coordinates)

The reason I am asking for the maximum area is so that I don't come up with a polygon like the one below:

crooked polygon <== Figure 2

What I need is the algorithm to come up with the set of coordinates for the boundary. An algorithm which will allow me to come up with boundary coordinates for Figure 1.

  • 1
    possible duplicate of Concave Hull: Definition, Algorithms and Practical Solutions
    – Ian Turton
    Jan 24, 2011 at 16:41
  • 4
    No, not duplicate, this is convex hull, not concave Jan 24, 2011 at 17:24
  • 1
    Are you looking for code, theoretical references, or solutions in specific existing software environments?
    – WolfOdrade
    Jan 24, 2011 at 17:29
  • 1
    @Khaja No, you don't want to maximize the area, you want to minimize it among all convex polygons containing the points. (The only way to maximize the area is to use the entire world as the containing polygon.)
    – whuber
    Jan 24, 2011 at 19:15
  • 1
    @whuber Yeah, now I see what you mean, I want a convex polygon with the minimal area. My ultimate goal is to do a proximity search. The way we want our proximity search to work is: In a given city (convex hull), if we search for homes (each home has a coordinate) within "x" miles, it should give me all the homes which are either inside the convex hull or are at an orthogonal distance of less than "x" miles Jan 25, 2011 at 5:52

6 Answers 6


There are many algorithms to solve this problem (Wikipedia "Convex_hull_algorithms"):

  • Gift wrapping aka Jarvis march — O(nh): One of the simplest algorithms. It has O(nh) time complexity, where n is the number of points in the set, and h is the number of points in the hull. In the worst case the complexity is O(n2).
  • Graham scan — O(n log n): Slightly more sophisticated, but much more efficient algorithm. If the points are already sorted by one of the coordinates or by the angle to a fixed vector, then the algorithm takes O(n) time. [pseudo code]
  • QuickHull: Like the quicksort algorithm, it has the expected time complexity of O(n log n), but may degenerate to O(nh) = O(n2) in the worst case. [illustrated description]
  • Divide and conquer — O(n log n): This algorithm is also applicable to the three dimensional case.
  • Monotone chain — O(n log n): A variant of Graham scan which sorts the points lexicographically by their coordinates. When the input is already sorted, the algorithm takes O(n) time.
  • Incremental convex hull algorithm — O(n log n)
  • Marriage-before-conquest — O(n log h): Optimal output-sensitive algorithm.
  • Chan's algorithm — O(n log h): Simpler optimal output-sensitive algorithm .
  • Thank you for listing these @underdark ... which one is your pick?
    – Marin
    Oct 25, 2018 at 15:44
  1. Convex Hull in GRASS GIS

  2. Convex Hull in Qgis Vector Tools (very easy to use):

enter image description here


Hawth's Tools for ArcGIS has this functionality. Plus a script for ArcInfo 10.

There is also convex hull tool in QuantumGIS via ftools plugin.


What you want is the Convex hull. In PostGIS there is a function (actually GEOS) that gives you the Convex hull, ST_ConvexHull(geometry).

At wikipedia there is a lot of info about concave hulls.


If you want an algorithm to do this (rather than packages that can do it) then I'd think you would need to triangulate the data; or basically define a line from each point to every other point. Then, starting at (say) the point with the highest Y value, trace a route around the outside following the connected line with the smallest exterior angle/bearing.

You would be able to speed up the tracing by throwing away intersecting lines first. The external boundary won't have intersections.

btw - FME will do this too with the ConvexHullAccumulator or ConvexHullReplacer transformers!


If you're interested in looking at an existing algorithm implemented in code, NetTopologySuite has an algorithm to do this

See ConvexHull.cs

Incidentally NTS and a bunch of other libraries are wrapped up in a cool project called DotSpatial, found here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.