BY G2 INTEGRATED SOLUTIONS
In the last post we loaded the APDM 5 / PODS ESRI Spatial 5 LineLoop table. Prior to that we loaded StationSeries. One task remains to complete the pipeline centerline; we’ll finish by loading ControlPoint.
The ControlPoint feature class stores points representing the pipeline centerline. Traditionally, Points of Inflection (P.I.s) from an as-built survey comprise the centerline. P.I.s define centerline turns in the horizontal plane, and are usually expressed in distance and deflection terms. The PODS ESRI Spatial / APDM centerline can store a 3D centerline, so you may want to include critical elevation points for vertical control. In any event, the control points should comprise all the vertices of their related station series features. Station series are constructed by connecting the control points.
For our purposes it suffices to convert our hypothetical Raw Pipeline Routes features to points, and then load these into the ControlPoint feature class. Those of you fortunate to possess an ArcInfo license can use the ArcToolbox –> Data Management Tools –> Features –> Feature Vertices to Pointstool to do the job. Sadly, ESRI is inordinately proud of this tool; the ArcView and ArcEditor hoi polloi are fresh out of luck! This seems grossly unfair, especially when two dozen lines of Python script tool will do the trick. In the public interest, here’s the guts of it, sans comments and error handling:
import arcpy inputPolylineFeatureLayer = arcpy.GetParameterAsText(0) outputPointFeatureClass = arcpy.GetParameterAsText(1) outName = outputPointFeatureClass.split(“\\”)[-1] outPath = “\\”.join(outputPointFeatureClass.split(“\\”)[:-1]) arcpy.CreateFeatureclass_management(outPath, outName, “POINT”, inputPolylineFeatureLayer, \ ”SAME_AS_TEMPLATE”, “SAME_AS_TEMPLATE”, inputPolylineFeatureLayer) outputFields = arcpy.ListFields(outputPointFeatureClass) inPolylineRows = arcpy.SearchCursor(inputPolylineFeatureLayer) outPointRows = arcpy.InsertCursor(outputPointFeatureClass) for inPolylineRow in inPolylineRows: inPolyline = \ inPolylineRow.getValue(arcpy.Describe(inputPolylineFeatureLayer).shapeFieldName) partCount = inPolyline.partCount partNum = 0 while partNum < partCount: pntArray = inPolyline.getPart(partNum) pntCount = pntArray.count pntNum = 0 while pntNum < pntCount: outPointRow = outPointRows.newRow() outPointRow.setValue(“Shape”, pntArray.getObject(pntNum)) for field in outputFields: if field.type <> “Geometry” and field.type <> “OID”: outPointRow.setValue(field.name, inPolylineRow.getValue(field.name)) outPointRows.insertRow(outPointRow) pntNum = pntNum + 1 partNum = partNum + 1 del outPointRow, outPointRows, inPolylineRow, inPolylineRows
For steely-eyed Python code-slingers, the above is fairly self explanatory. It could be more compact, but with less clarity. And yeah, ArcPy cursors are cool. Implementation of the script tool is left as an exercise for the reader. Note this code uses Arc 10 functionality, so don’t try this at home in Arc 9.3.x. (It can be done in 9.3.x, but alas, time is lacking.)
For the majority of you now ready to pluck out your slightly less steely eyeballs, it’s simpler to download the free Eagle Polyline Vertices to Points Arc 10 Python script tool from theGeoprocessing Model and Script Tool Galleryat the ArcGIS Resource Center. After unzipping the download file, drag the Eagle Generic Tools toolbox from ArcCatalog and drop it into the ArcMap ArcToolbox window to ready the tool for use:
Double-click the Polyline Vertices to Points tool to activate it:
In the Polyline Vertices to Points tool window, select Raw Pipeline Routes from the Input Polyline Feature Class pull down, and specify the output feature class in the Output Point Feature Class text box. Press the OK button in the Polyline Vertices to Points tool window to execute.
To prepare for load, add a field of type GUID called PointGUID to Raw Pipelines Routes Points. Apply CalcGUID() in the Field Calculatoras described in How to Generate GUIDs in ArcMapto populate PointGUID. Add a second field of type Double and name it MeasureValue. Use the expression !Shape.firstPoint.M! in the Field Calculator to populate MeasureValue. (Don’t forget to select the Python parser in the Field Calculator; those of you using 9.3.x should use the Calculate Fieldtool, instead.)
We’ll use the ArcToolbox Appendtool to load features from Raw Pipeline Routes Points feature class into ControlPoint:
In the Append tool window, select Raw Pipeline Routes Points in the Input Datasets pull down; select ControlPoint in the Target Dataset pull down; specify NO_TEST in the Schema Type pull down, and use these field mappings in the Field Map control:
• Target Field – Source Field
• EventID – PointGUID
• OriginEventID – PointGUID
• RouteEventID – ContinuousGUID
• MeasureValue – MeasureValue
• SeriesEventID – EngineeringGUID
• StationValue – MeasureValue
Press the OK button in the Append tool window, and Prest-o Change-o! Control points are loaded!YAY!Do an Identify on a ControlPoint feature in ArcMap; you should be able to trace relationships to the parent station series features:
And there it is. The centerline is loaded!I know what you’re thinking: “Is this his eighth post, or ninth?” To tell you the truth, in all this excitement, I’ve kinda lost track myself. But being as this is a GIS blog, the most powerful kind of blog in the world, and could blow your head clean off, you’ve got to ask yourself one question. Do you feel lucky? Well, do ya?
If so, hang around. In the next post we’ll do it all the EASY WAY!!!