SelectByShape()

Summary

Selects the map features located inside a shape.

Changes

Optional options array introduced in Version 5.0.

Syntax

n_selected = SelectByShape (string set_name, string operation, array shape [, array options])

Argument Contents
set_name The name of the selection set.
operation The operation to perform, as indicated below
shape An array of coordinates defining the area to search
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.

Notes

  • The options array is an optional argument.

  • All selection commands operate on the current layer.

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

  • Use SetSelectInclusion() to control whether features are selected only when fully contained in the search area, or when they intersect the search area.

Example

rh = LocateRecord("States|", "Name", {"Alaska"}, "True")
alaska_shape = GetArea(RH2ID(rh))
SetLayer("Airports")
n = SelectByShape("Alaska Airports", "Several", alaska_shape[3])
ShowMessage("There are " + i2s(n) + " airports in Alaska.")

Error Codes

Error Type Meaning
Error The set name, the operation type or the shape is invalid.
NotFound No features fall within the shape.

See Also

Function Summary
SelectByCircle() Selects map features that are located within a circle
SetSelectInclusion() Sets the inclusion status for spatial selection