VECTHIN

Perform vector thinning


EnvironmentsPYTHON :: EASI :: MODELER
Quick linksDescription :: Parameters :: Parameter descriptions :: Details :: Example :: Algorithm

Back to top

Description


VECTHIN takes input vector layer(s) and 'thins' them, producing new vector layer(s) as output.
Back to top

Parameters


vecthin(fili, filo, dbsl, thintol, dbsn, dbsd)

Name Type Caption Length Value range
FILI * str Input file name 1 -    
FILO str Output file name 0 -    
DBSL * List[int] Input vector segment(s) 1 -    
THINTOL * List[float] Thinning tolerance value 1 - 1 0.0 -
Default: 1.0
DBSN str Output segment name 0 - 8 Default: Thin
DBSD str Output segment description 0 - 64  

* Required parameter
Back to top

Parameter descriptions

FILI

Specifies the name of the PCIDSK image file containing the input vector layer(s) to be thinned.

FILO

Specifies the name of the PCIDSK file to receive the output thinned vector layer(s).

If FILO is not specified, FILI is used for the output. If FILO is specified but does not exist, a new file is created.

DBSL

Specifies the list of vector layers to be thinned.

THINTOL

Specifies the thinning tolerance value. The thinning tolerance must be greater than 0.0.

The units used for thinning tolerance are the same as those used for the vertex coordinates. The default is 1.0. If the thinning tolerance is equal to 0.0, the input is copied to the output.

DBSN

Specifies a name (up to 8 characters) for the new vector segment.

DBSD

Describes (in up to 64 characters) the contents or origins of the new vector data.

If this parameter is not specified, the description is taken from the input vector list.

Back to top

Details

VECTHIN "thins" a vector layer using the Douglas-Poiker algorithm.

Shapes with less than three vertices are not modified.

For more details on the Douglas-Poiker algorithm, see the Algorithm section.

Back to top

Example

Read vector layer 25 from irvine.pix and store the thinned vector in a new file named "oirvine.pix". Use a thinning tolerance of 10.

from pci.vecthin import vecthin

fili = "irvine.pix"
filo = "oirvine.pix"        # Nnew file to store thinning vector
dbsl = [25]                 # read vector layer 25 for thinning
thintol = [10.0]            # thinning tolerance 10
dbsn = "Thin"
dbsd = ""                   # defaults to the input vector description

vecthin(fili, filo, dbsl, thintol, dbsn, dbsd)
Back to top

Algorithm

Weeding: Douglas-Poiker algorithm

In a general sense, a weeding (filtering) algorithm is used to reduce the number of points (nodes) on a vector element without overtly affecting its general aspect.

The Douglas-Poiker algorithm works on a non-topological layer. The algorithm is dependent on the physical layout of the line. Lines with a great deal of variation between points will require more time to simplify than lines with the same number of points but less variation.

The parameters to the algorithm are:
Variables in the algorithm are:

How it works

The Douglas-Poiker algorithm comprises several phases. First, an anchor point and a floater must be defined. In the example below, at stage B, the anchor is p1 and the floater is p16. Notice how the anchor point remains stable through stages B to E. while the floater moves. This does not mean that the anchor remains completely stable, only that it moves at a slower rate than the floater point.


              p4       
   A        *  * *             *  *
        *         *                    *p16
       *p1        *  *p8      *
                      *        
                       * 
                        *
                           *p12


              p4       
   B        *  * *             *  *
       ___________*_______________________      
        *                              * p16
       *p1        *  *p8      *             ______
       _______________*______|____________  ______t
                       *     | d
                         *   | 
                             * p12

Phase 1

The line in the figure above requires 14+10+2+1 = 27 calculations of the value d (the perpendicular distance from a point to a corridor) before a single point is eliminated.

Stage 1b

At the start, the anchor is one end of the line and the floater is the other end of the line. For a closed polygon, the anchor is still the first point, while the floater starts at the next-to-last point. The floater and anchor points establish the corridor direction, while the tolerance (t) establishes the corridor width. Once the initial corridor is established, the point farthest away from the center of the corridor is determined. For stage B of the diagram above, the point p12 is farthest away from the corridor.

When the maximal point is determined (p12), it is placed on the stack. This maximal point is called the 'maximum perpendicular bisector'.

Determining the maximal point requires n-2 calculations of d (and the same number of comparisons). There is one comparison to determine if the maximal point falls within the corridor; if it does, every point between the anchor and the floater is eliminated.

At this stage, the maximal distance is not in the corridor, so proceed to stage 1c.

Stage 1c

The anchor is still the same as in stage 1b, but the floater has now become p12, the previous maximal point. Now, the maximal point between p1 and p12 is evaluated. The result here is p5. Determining that p5 is the maximal point requires 12 - 2=10 steps.

Because p5 is still larger than the tolerance, p5 is placed on the stack.

Stage 1d

The floater point is p5 while the maximal distance is at p3. Again, the maximal point is not within the tolerance, so p3 is placed on the stack. The number of steps needed to determine that p3 is the maximal point is 2.

Stage 1e

Finally, for last stage of Phase 1, we have a maximal point, p2, that falls within the tolerance; p2 is therefore eliminated from the line. If there were more points between the floater and the anchor at this stage, all of those points would be eliminated as well.

Phase 2

Each phase is determined by the movement of the anchor to a new position.

Now that p2 has been eliminated, the anchor can be moved. The anchor is moved to the last position of the float, p3, and the float is moved to the point on the top of the stack, which should be p5.

This is the maximal point, and it falls within the specified tolerance value. All points between p3 and p5, therefore, must be eliminated. Point p4 is deleted and p3 is connected to p5.

Phase 3

Because point p4 has been deleted, you must now move the anchor to p5. Point p11 is topped off the stack and the floater is moved to it. The maximal point is found, but because it does not fall within the tolerance, you must store it on the stack and move the float to it.

The float must move to the maximal point found in 1c. Now, a new maximal point must be found. Because the new one falls within the tolerance corridor, every point between the anchor and the float must be deleted. Figure E is the result.

Because the anchor has moved to a new position, a new phase begins. The maximal point here is outside of the tolerance corridor, so it is pushed onto the stack.

This is a degenerate case: the anchor and the float are directly linked, with no intervening points. In this case, the anchor is moved to the float, and the float is moved to the next point on the stack.

© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.