[Gdal-dev] remove colinear points from polygon

Martel, Christian Christian.Martel at drdc-rddc.gc.ca
Tue Mar 6 08:20:17 EST 2007


Mateusz,
I know many solutions to remove colinear point but I want to use the
available tools in OGR and get a quick and simple function. So here is
what I did in python. Don't know about performance againt another
method.

def simplifyPolygon(polygon):
    "remove colinear points from polygon boundary"
    gUnion = polygon				#geometry resulting of
Union of several polygons
    gHull = gUnion.ConvexHull()		#create a geometry without
colinear point
    gOver = gHull.Difference(gUnion)	#exceding part of the convexHull
    gFinal = gHull.Difference(gOver)	#get back the original geometry
without colinear point
    return gFinal

C,

> -----Original Message-----
> From: Mateusz Loskot [mailto:mateusz at loskot.net] 
> Sent: 6 mars 2007 03:14
> To: Martel, Christian
> Cc: gdal-dev at lists.maptools.org
> Subject: Re: [Gdal-dev] remove colinear points from polygon
> 
> Martel, Christian wrote:
> > Hi,
> > 
> > After merging several polygons with union, I get a big polygon with 
> > many colinear points. Example : with line (0 0,1 0,2 0), 1 0 is 
> > colinear with the others. How can I remove these middle colinear 
> > points on the polygon border ?
> 
> The most universal method is to use use Douglas-Peucker 
> algorithm for polyline simplification (implemented in GEOS).
> Another possible solution is to calculate and compare slopes 
> between adjacent points.
> 
> There is also an option based on distance formula and 
> ordering points of line, but this one is usually slower than 
> these two above.
> 
> Cheers
> --
> Mateusz Loskot
> http://mateusz.loskot.net
> 




More information about the Gdal-dev mailing list