Maptitude GISDK Help

Logistics.Clustering

Constructor

 

Logistics.Clustering

Initializes a new instance of the class with default settings.

 

Properties

 

Name Type Contents
LayerDB string Cluster layer database name
Filter string Optional. Selection set filter to select items from the LayerDB
Layer string If layer is open, name of the cluster layer
Set string Optional. If working with an open layer, the name of the selection set.
Iterations integer Optional. Number of iterations when clusters are balanced
NumberOfClusters integer The number of clusters to be built
Tolerance numeric Optional. Stopping condition when clusters are balanced
BalanceClusters string Optional. Name of the balancing option. Either Features, Size or Cost
ClusterSummary string Optional. Name of the output cluster summary table.
ClusterTable string Optional. Name of the cluster assignment output table

 

 

Methods

 

RestrictClusters(array opts)

Options to restrict cluster size by values in a field in the cluster layer

 

Option Type Description
opts array
Field string Name of the field
Value numeric Maximum value for each cluster

 

Run()

Creates the clusters and returns a status of the run

 

 

Example

 

macro "Clustering"

    on error do

        ShowMessage(GetLastError())

        return()

    end

 

    // Add a towns layer to the current map

    folder = RunMacro("G30 Tutorial Folder")

    layer_name = AddLayer(,"Cities & Towns", folder + "CTPlace.cdf","Cities & Towns",  )

    SetLayer(layer_name)

     

    // Cluster points based on geography and population

    obj = CreateObject("Logistics.Clustering")

    obj.Layer = layer_name

    obj.Set= null

    obj.NumberOfClusters = 10

    obj.Tolerance = 1

    obj.Iterations = 20

    obj.RestrictClusters({Field: "Population", Value: 50000000})

    obj.CalculateCosts({ Euclidean: true })

    obj.ClusterSummary = GetRandFileName("*.bin") // optional

    obj.ClusterTable = GetRandFileName("*.bin") // optional

    ok = obj.Run()

    

   // get the cluster results

    results = obj.GetResults()

    data  = results.Data

    

    // Open the result tables

    summary_table = Opentable("summary",  "FFB",{data.ClusterSummary,},)

    assigment_table = Opentable("Assigment",  "FFB",{data.ClusterTable,},)

    

    // Join the assignment table to the Cities & Towns layer

    joined_view = JoinViews("cluster_assigments" , layer_name + ".ID", assigment_table + ".ID", )

    a = GetFields(joined_view , "All")

    

    // Create a theme, one category for each seed

    SetView(joined_view )

    theme_field = "[" + joined_view + "].[" +assigment_table +"].[Cluster ID]"

    theme_name = CreateTheme( "Parcel Clusters", theme_field   , "Categories", 10 ,)

    // set theme  styles

    RunMacro("G30 new layer default settings", layer_name )

    SetIconSize(, 8)

    colors = RunMacro("G30 setup colors")

    colors = SubArray(colors,3,10)

    SetThemeIconColors( theme_name, colors)

    ShowTheme(  , theme_name )

    RedrawMap()

endmacro

 

 

See Also:

AddLayerDB

AddTables

Calculate Tables

Caliper.Charts

CC.ModifyTableOperations

CC.Table

Clustering

Data.Finder

Data.Geocoder

PostgreSQLConnect

PostgreSQLCommand

Routing.Bands

Routing.Path

Routing.Router

Table

Utilities.Mail

 

 

©2025 Caliper Corporation www.caliper.com