POST
|
I recently migrated my SDE geodatabase from SQL 2005 to SQL 2008. The SHAPE.area and SHAPE.len fields automatically changed to SHAPE.STArea() and SHAPE.STLencth(). I believe this is because of the new geometry data types available in SQL 2008 and later. A simple change in the field names doesn't really present a problem until I export feature classes to a file geodatabase. When feature classes are exported the SHAPE.STArea() and Length fields are retained, and additional Shape_Area and Shape_Length fields are created. Now there are redundant area and length fields and none can be deleted. Also, the area fields are different by as much as several square feet in some cases. How can I avoid or work around these additional fields. I replicate the entire SDE database as a file geodatabase, so one by one featureclass manipulation isn't ideal. Thanks, Justin
... View more
01-24-2014
06:33 AM
|
0
|
9
|
7676
|
POST
|
Thanks Neil. I had figured out that the data had a problem, but didn't know what it was. My routine worked with another set. Thanks again, Justin
... View more
01-27-2012
12:11 PM
|
0
|
0
|
20
|
POST
|
This is getting interesting. Can you please share your data? Not necessary all the features, just some that overlap but not generating area after the call. Thanks. Sure. With this set both my code, and the intersect tool find only one of 11 to be an intersecting polygon. Latest Code Protected Overrides Sub OnClick() Try Dim pMap As IMap = My.ArcMap.Document.FocusMap Dim pFLIndex As IFeatureLayer = pMap.Layer(0) Dim pFLSections As IFeatureLayer = pMap.Layer(1) Dim pFCSections As IFeatureClass = pFLSections.FeatureClass 'Get feature from Index Layer Dim pIndexFeature As IFeature = Nothing Dim pCursor As ICursor = pFLIndex.Search(Nothing, False) pIndexFeature = pCursor.NextRow 'MsgBox(pBufFeature.OID & " " & pIndexFeature.OID) Dim pSpatialFilter As New SpatialFilter pSpatialFilter.Geometry = pIndexFeature.Shape pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects Dim pSelSet As ISelectionSet = pFCSections.Select(pSpatialFilter, esriSelectionType.esriSelectionTypeIDSet, esriSelectionOption.esriSelectionOptionNormal, Nothing) MsgBox(pSelSet.Count) 'get selected features from Sections 'Dim pFeatSel As IFeatureSelection = pFLSections 'Dim pSelFeats As ISelectionSet = pFeatSel.SelectionSet 'MsgBox(pSelFeats.Count) 'Loop through features in Buffered sections and calculate overlap sq ft Dim pCur As IFeatureCursor = Nothing Dim pBufFeature As IFeature = Nothing pSelSet.Search(Nothing, False, pCur) pBufFeature = pCur.NextFeature Do Until pBufFeature Is Nothing Dim dblOverLap As Double = GetArea(pBufFeature, pIndexFeature) 'Calls function pBufFeature.Value(10) = dblOverLap pBufFeature.Store() pBufFeature = pCur.NextFeature Loop My.ArcMap.Document.ActiveView.Refresh() Catch ex As Exception MsgBox(ex.ToString & vbCr & vbCr & ex.Message) End Try My.ArcMap.Application.CurrentTool = Nothing End Sub Private Function GetArea(ByVal FeatureA As IFeature, ByVal FeatureB As IFeature) As Double Dim SourceArea As IArea Dim TargetArea As IArea Dim TopoOp As ITopologicalOperator Dim IntersectArea As IArea SourceArea = FeatureA.ShapeCopy 'FeatureA and FeatureB are the polygons to be checked for overlap TargetArea = FeatureB.ShapeCopy TopoOp = TargetArea Dim TopoOp2 As ITopologicalOperator2 = TargetArea TopoOp2.IsKnownSimple_2 = False TopoOp2.Simplify() IntersectArea = TopoOp2.Intersect(SourceArea, ESRI.ArcGIS.Geometry.esriGeometryDimension.esriGeometry2Dimension) GetArea = IntersectArea.Area '/ SourceArea.Area) * 100 'returns the percentage of first polygon which overlaps second polygon 'SourceArea = Nothing 'TargetArea = Nothing 'TopoOp = Nothing 'IntersectArea = Nothing End Function
... View more
01-27-2012
06:54 AM
|
0
|
0
|
44
|
POST
|
No. I tried the simplify work around as well. If I run the intersect geoprocessing tool in ArcMap same results. Only gets some of the features. I don't get why a select by location in ArcMap will get all of the intersecting features and programmatically a spatial filter will get them too, yet I can't get all the intersections in the GUI or through code with the intersect tools. I have to do this for several datasets each containing several hundred intersecting polygons. Maybe its just someting with this test dataset I am using?
... View more
01-27-2012
06:39 AM
|
0
|
0
|
44
|
POST
|
Any reason for using IntesectEx on ITopologicalOperator6 rather than Intersect of ITopologicalOperator? Another thing, in your search cursor for the layer 2, if you create a spatial filter with intersect relationship with the layer 1 geometry (single polygon), are you getting all the features you expect? I tried both IntersectEx of ITopologicalOperator6 and Intersect of ITopoligicalOperator and they produced the same results. I was just getting the feature selection, but I tried your test and yes SpatialFilter intersect relationship will get all the features I expected. So, the spatial filter recognizes there is an intersection, but topological operator does not. Is there another interface that will get the geometry so i can calculate area? Thanks for the help.
... View more
01-26-2012
11:56 AM
|
0
|
0
|
44
|
POST
|
I am trying to calculate the area (square feet) of overlap (intersection) of polygons in two shapefiles. Layer 1 has only one polygon. Layer two has many and I know that all of them intersect with the polygon in layer 1. I am trying to calculate the area of the overlap. My code loops through every feature in layer 2 and intersects it with the polygon in Layer 1 using iTopologicalOperator6.IntersectEx. The problem is that the area it calculates is zero for most of the features. It only gets an area for some. As I mentioned, in reality, all polygons intersect. My code is attached. I verified that the loop is getting all features, so it seems the function using the .intersectex method has a problem. Any help is appreciated. Thanks. Justin Protected Overrides Sub OnClick() Try Dim pMap As IMap = My.ArcMap.Document.FocusMap Dim pFLIndex As IFeatureLayer = pMap.Layer(0) Dim pFLSections As IFeatureLayer = pMap.Layer(1) 'get selected features from Sections Dim pFeatSel As IFeatureSelection = pFLSections Dim pSelFeats As ISelectionSet = pFeatSel.SelectionSet 'MsgBox(pSelFeats.Count) 'Get feature from Index Layer Dim pIndexFeature As IFeature = Nothing Dim pCursor As ICursor = pFLIndex.Search(Nothing, False) pIndexFeature = pCursor.NextRow 'MsgBox(pBufFeature.OID & " " & pIndexFeature.OID) 'Loop through features in Buffered sections and calculate overlap sq ft Dim pCur As IFeatureCursor = Nothing Dim pBufFeature As IFeature = Nothing pSelFeats.Search(Nothing, False, pCur) pBufFeature = pCur.NextFeature Do Until pBufFeature Is Nothing Dim dblOverLap As Double = GetArea(pBufFeature, pIndexFeature) 'Calls function pBufFeature.Value(10) = dblOverLap pBufFeature.Store() pBufFeature = pCur.NextFeature Loop My.ArcMap.Document.ActiveView.Refresh() Catch ex As Exception MsgBox(ex.ToString & vbCr & vbCr & ex.Message) End Try My.ArcMap.Application.CurrentTool = Nothing End Sub Private Function GetArea(ByVal FeatureA As IFeature, ByVal FeatureB As IFeature) As Double Dim SourceArea As IArea Dim TargetArea As IArea Dim TopoOp As ITopologicalOperator6 Dim IntersectArea As IArea SourceArea = FeatureA.ShapeCopy 'FeatureA and FeatureB are the polygons to be checked for overlap TargetArea = FeatureB.ShapeCopy TopoOp = TargetArea IntersectArea = TopoOp.IntersectEx(SourceArea, False, ESRI.ArcGIS.Geometry.esriGeometryDimension.esriGeometry2Dimension) GetArea = IntersectArea.Area '/ SourceArea.Area) * 100 'returns the percentage of first polygon which overlaps second polygon SourceArea = Nothing TargetArea = Nothing TopoOp = Nothing IntersectArea = Nothing End Function
... View more
01-26-2012
07:18 AM
|
0
|
11
|
3687
|
POST
|
Maybe you need to close the polygon by adding the first point to the end of the point collection. This code worked for me. Yup, that did it. Thanks a lot Tim. Justin
... View more
01-19-2012
12:13 PM
|
0
|
0
|
23
|
POST
|
Thanks for the help, Tim. I implemented your suggestions. The routine is still creating features with empty geometries. Any idea why it would add a row to the table but not add take the geometry? The shape field does show 'polygon' but when I select or try to zoom to one onf the new features - nothing.
... View more
01-19-2012
10:45 AM
|
0
|
0
|
23
|
POST
|
Here is a code sample that is getting close. It will create the new features in the table but there is no feature associated with it. Seems like it isn't taking the geometry. Dim pMap As IMap = My.ArcMap.Document.FocusMap Dim pFLayer As IFeatureLayer = pMap.Layer(0) Dim pFC As IFeatureClass = pFLayer.FeatureClass Dim pCursor As IFeatureCursor = pFC.Search(Nothing, False) Dim pFeature As IFeature = pCursor.NextFeature Dim pEnv As New Envelope Dim pPoly As New Polygon Dim uid As ESRI.ArcGIS.esriSystem.UID uid = New ESRI.ArcGIS.esriSystem.UIDClass() uid.Value = "esriEditor.Editor" Dim editor As IEditor editor = CType(My.ArcMap.Application.FindExtensionByCLSID(uid), IEditor) Dim pDS As IDataset = pFLayer.FeatureClass Dim pWS As IWorkspace = pDS.Workspace 'Check to see if a workspace is already being edited. If editor.EditState = esriEditState.esriStateNotEditing Then editor.StartEditing(pWS) End If Do Until pFeature Is Nothing Dim pNewFeat As IFeature = pFC.CreateFeature pEnv.XMax = pFeature.Shape.Envelope.XMax + 100 pEnv.XMin = pFeature.Shape.Envelope.XMin - 100 pEnv.YMax = pFeature.Shape.Envelope.YMax + 100 pEnv.YMin = pFeature.Shape.Envelope.YMin - 100 Dim LL As New Point LL.PutCoords(pEnv.XMin, pEnv.YMin) Dim LR As New Point LR.PutCoords(pEnv.XMax, pEnv.YMin) Dim UR As New Point UR.PutCoords(pEnv.XMax, pEnv.YMax) Dim UL As New Point UL.PutCoords(pEnv.XMin, pEnv.YMax) pNewFeat.Shape = pPoly pNewFeat.Value(3) = pFeature.Value(3) pNewFeat.Store() pFeature = pCursor.NextFeature Loop editor.StopEditing(True) My.ArcMap.Document.ActiveView.Refresh()
... View more
01-19-2012
09:04 AM
|
0
|
0
|
23
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|