AddComplexPolygon

AddComplexPolygon adds a new complex (included/excluded regions) polygon shape. Returns a Polygon object. Using this method, you can create a complex polygon, save it to a BLN file and use it to assign NoData values to a grid file.

 

Occurrence of Complex Polygon

 

Complex polygons can be separate islands as shown for Hawaii (top), or can contain lakes that form holes in the larger area (bottom). In both cases, each is a single object type.

Syntax

object.AddComplexPolygon( Vertices, PolyCounts )

Parameter

Type

Default

Description

Vertices

Array of Doubles

required; This provides the array containing each vertex in the complex polygon.

PolyCounts

Array of Longs

required; This provides the number of vertices in each sub polygon.

Remarks

Either page units or map coordinates are used in the arrays. When the complex polygon is added to the plot, use page units for the vertices' coordinates. When the complex polygon is added to a map layer, use map coordinates to specify the vertices' coordinates. Vertices is an array containing alternating x,y coordinates. This assumes the entire array is used. VB users can use

Complex polygons consist of one or more polygons. For example, consider an outer square and an inner triangle. The square would consist of four vertices: x1,y1 x2,y2 x3,y3 x4,y4 and the triangle would consist of three vertices: x5,y5 x6,y6 x7,y7. The square has a vertex count of four and the triangle has a vertex count of three. The arrays appear as follows:

Vertices: x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6,x7,y7

PolyCounts: 4,3

Example 1

AddComplexPolygon allows polygons with included and excluded regions to be created. This example demonstrates how to create a complex polygon using an array of doubles named Coordinates and an array of longs named NumPolygons. The even numbered elements within the Coordinates array represent x values, while the odd numbered elements represent their corresponding y values. The elements within the NumPolygons array represent the simple polygons defined within the complex polygon; their values indicating the number of coordinate pairs needed to create them.

'declare ComplexPolygon object

Dim ComplexPolygon As Object

 

'declare Coordinates array and set element values

Dim Coordinates(23) As Double

Coordinates(0) = 3.44: Coordinates(1) = 4.06

Coordinates(2) = 1.10: Coordinates(3) = 6.39

Coordinates(4) = 3.44: Coordinates(5) = 8.73

Coordinates(6) = 5.75: Coordinates(7) = 6.39

Coordinates(8) = 3.36: Coordinates(9) = 8.07

Coordinates(10) = 5.01: Coordinates(11) = 6.42

Coordinates(12) = 3.36: Coordinates(13) = 4.75

Coordinates(14) = 1.71: Coordinates(15) = 6.42

Coordinates(16) = 1.71: Coordinates(17) = 8.07

Coordinates(18) = 5.01: Coordinates(19) = 8.07

Coordinates(20) = 5.01: Coordinates(21) = 4.75

Coordinates(22) = 1.71: Coordinates(23) = 4.75

 

'declare NumPolygons array and set element values

Dim NumPolygons(2) As Long

NumPolygons(0) = 4

NumPolygons(1) = 4

NumPolygons(2) = 4

 

'create the complex polygon

Set ComplexPolygon = Shapes.AddComplexPolygon(Vertices:=Coordinates, _

PolyCounts:= NumPolygons)

Example 2

This script displays all the methods and properties in the Shapes collection.

Used by: Shapes collection

 

See Also

Home | Insert | Polygon