SelectNearestFeatures()

Summary

Selects a feature in the current layer nearest to each feature in another layer or selection set.

Changes

Optional options array introduced in Version 5.0.

Syntax

n_selected = SelectNearestFeatures(string set_name, string operation, string search_layer_set, real threshold [, array options])

Argument Contents
set_name The name of the selection set
operation The operation to be performed, as described below
search_layer_set The name of the layer and selection set around which to search, in the form "layer_name|set_name"
threshold The maximum distance to search around each feature in the search layer
Operation Meaning
several Replaces the contents of the selection set
less Removes features from the selection set
more Adds features to the selection set
subset Selects a subset of the selection set
Option Type Contents
Inclusion String "Enclosed" or "Intersecting", overriding the current setting; for more information, see SetSelectInclusion()
Max Integer Maximum number of records to select
Display Boolean "True" or "False" overriding the current setting; for more information, see SetSelectDisplay()
Auto Redraw Boolean "True" or "False" overriding the current setting; for more information, see SetSelectAutoRedraw()
Source And String A selection set on the current layer that records must be in to be selected
Source Not String A selection set on the current layer that records must not be in to be selected

Returns

An integer indicating the number of records in the selection set. The number will be less than the number of features in search_layer_set if there are no current layer features within the threshold for one or more search_layer_set features.

Notes

  • The options array is an optional argument.

  • All selection commands operate on the current layer.

  • The search layer can be points or areas. Use SelectByVicinity() to select features based on line layers.

  • If the set does not already exist, SelectNearestFeatures() creates it.

  • The search layer can be the same as the current layer.

Example

n = SelectNearestFeatures("Nearest Hospitals", "Several",
"Airports|Accidents", 25.0)

Error Codes

Error Type Meaning
Error The set name or operation type is invalid
NotFound The search layer or selection set do not exist

See Also

Function Summary
LocateNearestRecord() Finds the map feature nearest a point location
LocateNearestRecords() Finds the map features nearest a point location
SelectByVicinity() Selects map features located in or near features in another layer or selection set