I am working on a tool to convert point to line using ArcObjects in C#. I can understand the arcpy function but is there an example to show how to convert a point layer into a line feature and save as a new line layer? Any code snippet will help.#PointsToLine
This is a portion of the code I used in a tool that converted points (pPointFLayer) to a line (pLineFLayer)
Dim pPointFLayer As ESRI<SPAN class="punctuation token">.</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Carto<SPAN class="punctuation token">.</SPAN>IFeatureLayer Dim pFCursor As ESRI<SPAN class="punctuation token">.</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Geodatabase<SPAN class="punctuation token">.</SPAN>IFeatureCursor Dim pFeature As ESRI<SPAN class="punctuation token">.</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Geodatabase<SPAN class="punctuation token">.</SPAN>IFeature Dim pFirstPointShape As ESRI<SPAN class="punctuation token">.</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Geometry<SPAN class="punctuation token">.</SPAN>IGeometry Dim pFirstPoint As ESRI<SPAN class="punctuation token">.</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Geometry<SPAN class="punctuation token">.</SPAN>IPoint Dim pSecondPointShape As ESRI<SPAN class="punctuation token">.</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Geometry<SPAN class="punctuation token">.</SPAN>IGeometry Dim pSecondPoint As ESRI<SPAN class="punctuation token">.</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Geometry<SPAN class="punctuation token">.</SPAN>IPoint Dim pLine As ESRI<SPAN class="punctuation token">.</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Geometry<SPAN class="punctuation token">.</SPAN>ILine Dim pSegColl As ESRI<SPAN class="punctuation token">.</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Geometry<SPAN class="punctuation token">.</SPAN>ISegmentCollection Dim pGeomColl As ESRI<SPAN class="punctuation token">.</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Geometry<SPAN class="punctuation token">.</SPAN>IGeometryCollection Dim pPolyline As ESRI<SPAN class="punctuation token">.</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Geometry<SPAN class="punctuation token">.</SPAN>IPolyline Dim pIFBuffer As ESRI<SPAN class="punctuation token">.</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Geodatabase<SPAN class="punctuation token">.</SPAN>IFeatureBuffer Dim pIFCursor As ESRI<SPAN class="punctuation token">.</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Geodatabase<SPAN class="punctuation token">.</SPAN>IFeatureCursor pIFCursor <SPAN class="operator token">=</SPAN> pLineFLayer<SPAN class="punctuation token">.</SPAN>FeatureClass<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Insert</SPAN><SPAN class="punctuation token">(</SPAN>True<SPAN class="punctuation token">)</SPAN> pIFBuffer <SPAN class="operator token">=</SPAN> pLineFLayer<SPAN class="punctuation token">.</SPAN>FeatureClass<SPAN class="punctuation token">.</SPAN>CreateFeatureBuffer pFCursor <SPAN class="operator token">=</SPAN> pPointFLayer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Search</SPAN><SPAN class="punctuation token">(</SPAN>Nothing<SPAN class="punctuation token">,</SPAN> False<SPAN class="punctuation token">)</SPAN> pFeature <SPAN class="operator token">=</SPAN> pFCursor<SPAN class="punctuation token">.</SPAN>NextFeature Do Until pFeature Is Nothing FirstGroupID <SPAN class="operator token">=</SPAN> pFeature<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Value</SPAN><SPAN class="punctuation token">(</SPAN>pFeature<SPAN class="punctuation token">.</SPAN>Fields<SPAN class="punctuation token">.</SPAN><SPAN class="token function">FindField</SPAN><SPAN class="punctuation token">(</SPAN>cboField<SPAN class="punctuation token">.</SPAN>Text<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> pFirstPointShape <SPAN class="operator token">=</SPAN> pFeature<SPAN class="punctuation token">.</SPAN>Shape pFirstPoint <SPAN class="operator token">=</SPAN> pFirstPointShape pFeature <SPAN class="operator token">=</SPAN> pFCursor<SPAN class="punctuation token">.</SPAN>NextFeature If pFeature Is Nothing Then Exit Do pSecondPointShape <SPAN class="operator token">=</SPAN> pFeature<SPAN class="punctuation token">.</SPAN>Shape pSecondPoint <SPAN class="operator token">=</SPAN> pSecondPointShape pLine <SPAN class="operator token">=</SPAN> <SPAN class="token function">CreateLn</SPAN><SPAN class="punctuation token">(</SPAN>pFirstPoint<SPAN class="punctuation token">,</SPAN> pSecondPoint<SPAN class="punctuation token">)</SPAN> pSegColl <SPAN class="operator token">=</SPAN> New <SPAN class="token class-name">ESRI<SPAN class="punctuation token">.</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Geometry<SPAN class="punctuation token">.</SPAN>Path</SPAN> pSegColl<SPAN class="punctuation token">.</SPAN><SPAN class="token function">AddSegment</SPAN><SPAN class="punctuation token">(</SPAN>pLine<SPAN class="punctuation token">)</SPAN> pGeomColl <SPAN class="operator token">=</SPAN> New <SPAN class="token class-name">ESRI<SPAN class="punctuation token">.</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Geometry<SPAN class="punctuation token">.</SPAN>Polyline</SPAN> pGeomColl<SPAN class="punctuation token">.</SPAN><SPAN class="token function">AddGeometry</SPAN><SPAN class="punctuation token">(</SPAN>pSegColl<SPAN class="punctuation token">)</SPAN> pPolyline <SPAN class="operator token">=</SPAN> pGeomColl pIFBuffer<SPAN class="punctuation token">.</SPAN>Shape <SPAN class="operator token">=</SPAN> pPolyline pIFCursor<SPAN class="punctuation token">.</SPAN><SPAN class="token function">InsertFeature</SPAN><SPAN class="punctuation token">(</SPAN>pIFBuffer<SPAN class="punctuation token">)</SPAN> Loop Private Function <SPAN class="token function">CreateLn</SPAN><SPAN class="punctuation token">(</SPAN>ByRef pPointFrom As ESRI<SPAN class="punctuation token">.</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Geometry<SPAN class="punctuation token">.</SPAN>IPoint<SPAN class="punctuation token">,</SPAN> ByVal pPointTo As ESRI<SPAN class="punctuation token">.</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Geometry<SPAN class="punctuation token">.</SPAN>IPoint<SPAN class="punctuation token">)</SPAN> As ESRI<SPAN class="punctuation token">.</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Geometry<SPAN class="punctuation token">.</SPAN>ILine CreateLn <SPAN class="operator token">=</SPAN> New <SPAN class="token class-name">ESRI<SPAN class="punctuation token">.</SPAN>ArcGIS<SPAN class="punctuation token">.</SPAN>Geometry<SPAN class="punctuation token">.</SPAN>Line</SPAN> CreateLn<SPAN class="punctuation token">.</SPAN><SPAN class="token function">PutCoords</SPAN><SPAN class="punctuation token">(</SPAN>pPointFrom<SPAN class="punctuation token">,</SPAN> pPointTo<SPAN class="punctuation token">)</SPAN> End Function <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
You could call the existing geo-processing tool, that would be easiest. One way to do this is to be using the IGeoProcessor object and call the tool.
Search the API help there are numerous examples of tools being run using this approach.
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.