Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

Edit:

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
1  
possible duplicate of Concave Hull: Definition, Algorithms and Practical Solutions –  iant Jan 24 '11 at 16:41
3  
No, not duplicate, this is convex hull, not concave –  Nicklas Avén Jan 24 '11 at 17:24
1  
Are you looking for code, theoretical references, or solutions in specific existing software environments? –  WolfOdrade Jan 24 '11 at 17:29
    
What software / platform are you wiling to use for that? –  radek Jan 24 '11 at 18:18
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 '11 at 19:15
show 6 more comments

6 Answers

up vote 6 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
add comment

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
add comment

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
add comment

Hallo

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 about concave hull there is a lot of info.

HTH Nicklas

share|improve this answer
add comment

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
add comment

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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