When running large spatial selections in ArcSDE geodatabases, the Select Layer By Location geoprocessing tool returns the following error message: "Error 000520: Unexpected Topo Engine error; Failed to execute: Select By Location".
上次发布: December 18, 2015ArcSDE/Enterprise Geodatabase
Non-reproducible. If this is still being encountered in a current supported release, please contact Support Services.
解决办法
1. Export datasets to a File Geodatabase to create selections.
2. Select objects interactively.
3. Use the ArcObjects code below to complete the Select By Location operation:
Public Sub SelectByLocation()
On Error GoTo ErrorHandler
Dim pFeatLayer As IFeatureLayer
Dim pPYFeatLayer As IFeatureLayer
Dim pMXDoc As IMxDocument
Dim pMap As IMap
Dim pSpatialFilter As ISpatialFilter
Dim pFeatCursor As IFeatureCursor
Dim pFeature As IFeature
Dim pPYGeometry As IGeometry
Dim pFeatSelection As IFeatureSelection
Set pMXDoc = ThisDocument
Set pMap = pMXDoc.FocusMap
'access the map layers
Set pFeatLayer = pMap.Layer(0)
Set pPYFeatLayer = pMap.Layer(1)
'get the py geometry
Set pFeatCursor = pPYFeatLayer.Search(Nothing, False)
Set pFeature = pFeatCursor.NextFeature()
Set pPYGeometry = pFeature.ShapeCopy()
Set pFeature = Nothing
Set pFeatCursor = Nothing
'setup the spatial filter
Set pSpatialFilter = New SpatialFilter
Set pSpatialFilter.Geometry = pPYGeometry
pSpatialFilter.GeometryField = pFeatLayer.FeatureClass.ShapeFieldName
pSpatialFilter.SpatialRel = esriSpatialRelIntersects
'do the selection
Set pFeatSelection = pFeatLayer
pFeatSelection.SelectFeatures pSpatialFilter, esriSelectionResultNew, False
pMXDoc.CurrentContentsView.Refresh 0
MsgBox "Done"
Exit Sub
ErrorHandler:
MsgBox "Error: " & Err.Description
End Sub
---
The above code assumes the first map layer is the roads layer; the next is the poly layer.