caseyogden

Spatial Filter

Discussion created by caseyogden on Feb 21, 2011
I have a record from a polygon layer already selected (Installation Area) and I would like to select all of the buildings within this polygon.  As this code stands it is selecting all of the buildings in the building layer and not within the Installation Area polygon.

Dim pLayer As Iplayer
Dim pLayer2 As Iplayer2
Dim pfSelLayer = IFeatureSelection
Dim pfSelLayer2 = IFeatureSelection

Set player = FindLayerByName(pMap, "Installation Area")
Set player2 = FindlayerByName(pMap, "Building")

Set pFSelLayer = pLayer
Set pFSelLayer2 = pLayer2


Dim pGeom As IGeometry
Set pSpFltr = new Spatial Filter
Set pSpFltr.Geometry = pGeom  'Would like to make the association here with pfSelLayer or pLayer
pSpFltr.GeometryField = "SHAPE"
pSpFltr.SpatialRel = esriSpatialRelIntersects

pFSelLayer2.SelectFeatures pSpFltr, esriSelectionNew, False

Outcomes