Line to points

572
2
06-29-2011 07:31 AM
MathieuCain
Occasional Contributor
Hello,

What I have:
- I have a line which is correctly geographically referenced.
- I know that the start and end nodes correspond to specific stations (i.e., points).
- The stations are sequential numbers based on some variable distance (e.g., Station 3408.52 is 2.91ft from Station 3405.61) - this distance may vary between stations.

What I want:
- I want to correctly position each station as a point along this line.

My proposed procedure:
- Create a table of all stations in sequential order, with a field containing distance to next one.
- Using the table, break the line at the set intervals (in sequential order)
- Export polyline nodes to a new point feature class (e.g., using ETGeoWizards)

Problem: How do I tackle my second step?
Tags (2)
0 Kudos
2 Replies
JonWebb
Emerging Contributor
The following VB script is from http://forums.esri.com/Thread.asp?c=93&f=987&t=106536

I tested it with a mxd containing a point file and a line file, the point file being first in the TOC. Do not run it in Edit mode. It works as long as the points are not at the beginning or end of the line as this results in lines of zero length.


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
0 Kudos
MathieuCain
Occasional Contributor
The following VB script is from http://forums.esri.com/Thread.asp?c=93&f=987&t=106536

I tested it with a mxd containing a point file and a line file, the point file being first in the TOC. Do not run it in Edit mode. It works as long as the points are not at the beginning or end of the line as this results in lines of zero length.


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


Thank you for the code. While I have not had an opportunity to try it out yet, I should probably clarify as maybe it wasn't quite clear in my problem definition, that I only have a list of station names, not their actual coordinates. The only stations that I do have coordinates for are the ones at the start and end of the line. Based on this, I would like to position the other stations along this line as point features.
0 Kudos