Take the 2-minute tour ×

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 sorry I wasn't precise about why I needed this. 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. Hope that clarifies a few things.

share|improve this question
possible duplicate of Concave Hull: Definition, Algorithms and Practical Solutions –  iant Jan 24 '11 at 16:41
No, not duplicate, this is convex hull, not concave –  Nicklas Avén Jan 24 '11 at 17:24
Are you looking for code, theoretical references, or solutions in specific existing software environments? –  WolfOdrade Jan 24 '11 at 17:29
@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 '11 at 19:15
@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 –  Khaja Minhajuddin Jan 25 '11 at 5:52

6 Answers 6

up vote 13 down vote accepted

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 .
share|improve this answer
+1 Nice overview of some of the methods out there. –  whuber Jan 26 '11 at 3:08
nice answer, very helpful. –  user two seven two three nine Oct 10 '14 at 19:18

1)Convex Hull in GRASS GIS: http://grass.fbk.eu/grass64/manuals/html64_user/v.hull.html

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

enter image description here

share|improve this answer

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.

share|improve this answer

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.

share|improve this answer

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!

share|improve this answer

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

share|improve this answer

Your Answer


