代码改变世界

【转载】split / break polylines at point intersections

2008-02-23 18:20  flyingfish  阅读(1750)  评论(1编辑  收藏  举报

关于如何将FeatureClass中线相互打断的讨论 - split / break polylines at point intersections

http://forums.esri.com/Thread.asp?c=93&f=1384&t=94285

ArcGIS Desktop - Geodatabase Topology forum
split / break polylines at point intersecti...   stephen eckhardt May 23, 2003
Re: split / break polylines at point inters...   Bradley Chopp Sep 30, 2003
Re: split / break polylines at point inters...   stephen eckhardt Sep 30, 2003
Re: split / break polylines at point inters...   Bradley Chopp Sep 30, 2003
Re: split / break polylines at point inters...   stephen eckhardt Sep 30, 2003
Re: split / break polylines at point inters...   Gourkishore Tripathy Oct 06, 2003
Re: split / break polylines at point inters...   tracy trople Jan 15, 2004
Re: split / break polylines at point inters...   Valentina Boycheva Dec 20, 2004
Re: split / break polylines at point inters...   Valentina Boycheva Dec 20, 2004
Re: split / break polylines at point inters...   Christie Johnson Oct 04, 2004
Re: split / break polylines at point inters...   Adriano Gomes Dec 20, 2004
• Top Print Reply Alert Moderator   
Subject split / break polylines at point intersections 
Author stephen eckhardt 
Date May 23, 2003 
Message I thought this would be an easy task to accomplish automatically but I have yet to find a way to break lines where they intersect points. I'm using 8.3 and new features such as the planarize button are extremly helpful. But if they have that I'm not sure why they don't have a feature to do the same with lines and point. Does anyone know an easy way to accomplish this task.

I have about 4000 points that intersect lines where the lines now need to be broken. I know I can set up a topology rule to find all these areas but is there a way to break all the line at once without going through each one individually.

Any thoughts or suggestions? 
  Stephen Eckhardt
GIS Analyst
Civil Solutions 
   
• Top Print Reply Alert Moderator   
Subject Re: split / break polylines at point intersections 
Author Bradley Chopp 
Date Sep 30, 2003 
Message Stephen,
Did you ever figure out this problem? I am coming across the exact same situation. I need to break my watermain polyline Feature Class where water valves(point FC) intersect. Any suggestions? I sure hope you didnt have to do that by hand!

Thanks,
Brad 
   
• Top Print Reply Alert Moderator   
Subject Re: split / break polylines at point intersections 
Author stephen eckhardt 
Date Sep 30, 2003 
Message the answer i got from tech support was unless you write some specific code, yes you have to do it (split the lines at points)individually. 
  Stephen Eckhardt
GIS Analyst
Civil Solutions 
   
• Top Print Reply Alert Moderator   
Subject Re: split / break polylines at point intersections 
Author Bradley Chopp 
Date Sep 30, 2003 
Message A gentleman in the Data Editing forum gave me this code to split all lines in one layer by all points in another. Note: It works funny while in an edit session. So, it is better to NOT Start Editing when using this code.

Brad 
 
Sub SplitAll()
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument

Dim pMap As IMap
Set pMap = pMxDoc.FocusMap

Dim pPointL As IFeatureLayer
Set pPointL = pMap.Layer(0) 'point layer to split lines with

Dim pLineL As IFeatureLayer
Set pLineL = pMap.Layer(1) 'line layer to be split


Dim pLineFC As IFeatureClass
Set pLineFC = pLineL.FeatureClass

Dim pPointFC As IFeatureClass
Set pPointFC = pPointL.FeatureClass

Dim pPointCursor As IFeatureCursor
Set pPointCursor = pPointFC.Search(Nothing, False)

Dim pPointF As IFeature
Set pPointF = pPointCursor.NextFeature

Do Until pPointF Is Nothing
Dim pPoint As IPoint
Set pPoint = pPointF.Shape

Dim pSF As ISpatialFilter
Set pSF = New SpatialFilter

With pSF
Set .Geometry = pPoint
.GeometryField = "Shape"
.SpatialRel = esriSpatialRelIntersects
End With

Dim pLineCursor As IFeatureCursor
Set pLineCursor = pLineFC.Search(pSF, True)

Dim pLineF As IFeature
Set pLineF = pLineCursor.NextFeature

Do Until pLineF Is Nothing
Dim pPolyCurve As IPolycurve
Set pPolyCurve = pLineF.Shape

Dim pToPoint As IPoint
Set pToPoint = pPolyCurve.ToPoint

Dim pFromPoint As IPoint
Set pFromPoint = pPolyCurve.FromPoint

If (pFromPoint.x = pPoint.x And pFromPoint.y = pPoint.y) Then
'do nothing
ElseIf (pToPoint.x = pPoint.x And pToPoint.y = pPoint.y) Then
'do nothing
Else
Dim pFeatureEdit As IFeatureEdit
Set pFeatureEdit = pLineF
pFeatureEdit.Split pPointF.Shape
End If
Set pLineF = pLineCursor.NextFeature
Loop

Set pPointF = pPointCursor.NextFeature

Loop

End Sub
 
   
• Top Print Reply Alert Moderator   
Subject Re: split / break polylines at point intersections 
Author stephen eckhardt 
Date Sep 30, 2003 
Message Thanks, I'll try it out. 
  Stephen Eckhardt
GIS Analyst
Civil Solutions 
   
• Top Print Reply Alert Moderator   
Subject Re: split / break polylines at point intersections 
Author Gourkishore Tripathy 
Date Oct 06, 2003 
Message I am using the above code given by Prem, which I changed like this, keeping all other lines of code intact.

Set pLineCursor = pLineFC.Search(pSF, False)

One pre-condition is all your points (in point layer) must fall exactly on the polyines (in polyine layer). Otherwise, it will not split. 
   
• Top Print Reply Alert Moderator   
Subject Re: split / break polylines at point intersections 
Author tracy trople 
Date Jan 15, 2004 
Message Do you know if it is possible to preform the above task with an point event theme and a geographic network line layer? I've tried this code with my data and it doesn't recognize the point event layer. I have saved the point layer as feature layer and it bails out when it tries to select a line. The error message says something like "no current recor". 
   
• Top Print Reply Alert Moderator   
Subject Re: split / break polylines at point intersections 
Author Valentina Boycheva 
Date Dec 20, 2004 
Message Tracy,

Did you check whether your point layer and geographic network layer are in the same projection? The spatial operators and interfaces will usually fail if this is not true - with or without generating an error message. 
  Valentina Boycheva
Senior GIS Programmer/Analyst
http://www.jonesedmunds.com
 
   
• Top Print Reply Alert Moderator   
Subject Re: split / break polylines at point intersections 
Author Valentina Boycheva 
Date Dec 20, 2004 
Message Deleted duplicate post. 
  Valentina Boycheva
Senior GIS Programmer/Analyst
http://www.jonesedmunds.com
 
   
• Top Print Reply Alert Moderator   
Subject Re: split / break polylines at point intersections 
Author Christie Johnson 
Date Oct 04, 2004 
Message I ran the code, it says I have to be in an edit session. Istart an edit session, run the code, and it says there is no edit session in progress. Also, this line of code keep highlighting when I click debug:
pFeatureEdit.Split pPointF.Shape
I am doing something wrong, but what? 
   
• Top Print Reply Alert Moderator   
Subject Re: split / break polylines at point intersections 
Author Adriano Gomes 
Date Dec 20, 2004 
Message Can not execute this script too.

My (.mxd) have first shape point and second shape lines.
When execuute the scrist my Status Bar of ArcView "say" Create, Edit or Execute a VBA code...

What is this?

Thank.
Adriano 
  Adriano Hantequeste Gomes
SESP-GEAC