HOW TO
You can use ArcView Spatial Analyst to convert a polyline theme that contains contour elevations into a floating point elevation GRID theme.
Code:
'-- Script: pline2pt.ave
'-- This script converts a polyline theme into a point
'-- theme, where each point represents each vertex on
'-- all polylines.
'
'-- This script should be run on a elevation contour
'-- line theme in order to prepare it for surface
'-- interpolation using the Spatial Analyst extension.
'
'-- To run:
'-- Make a View the active window
'-- Make your contour line theme is the active theme
'-- Ensure the contour line theme has a field that
'-- contains the elevation value for each line
'-- Set up input objects
theView = av.getactivedoc
theTheme = theView.Getactivethemes.get(0)
origFTab = theTheme.GetFTab
theFieldList = origFTab.GetFields
origShapeFld = origFTab.FindField("Shape")
elevFldChoice = MsgBox.ChoiceAsString
(theFieldList,
"Which field contains the contour elevation values",
"")
origElevFld = origFTab.FindField(elevFldChoice.asstring)
'-- Create the new point shapefile template
newShapefileName = FileDialog.Put("*.shp".asfilename,"*.shp","")
idBaseName = newShapefileName.GetBaseName.AsString.Trim.Left(4)
newFTab = FTab.MakeNew(newShapefileName,POINT)
'-- Populate the new shapefile with fields
newShapeFld = newFTab.FindField("Shape")
newElevFld = Field.Make("Elev",#FIELD_LONG,12,0)
newIDFld = Field.Make(idBaseName+"_"+"ID",#FIELD_LONG,12,0)
newFTab.AddFields({newElevFld,newIDFld})
'-- Process each polyline in the input line theme
for each rec in origFTab
av.ShowMsg("Converting Polylines to Vertex Points...")
av.SetStatus((rec+1/(origFTab.GetNumRecords)) *100)
thePolyline = origFTab.ReturnValue(origShapeFld,rec)
elevValue = origFTab.ReturnValue(origElevFld,rec)
'-- Process each part of the polyline
for each aListofPoints in (thePolyline.AsList)
pointCount = aListofPoints.Count
'-- Process each point in each polyline part, and populate the
'new shapefile with each vertex point you find.
for each i in (0..(pointCount - 1))
newPoint = aListofPoints.Get(i)
newRecNum = newFTab.AddRecord
newFTab.SetValue(newShapeFld,newRecNum,newPoint)
newFTab.SetValue(newElevFld,newRecNum,elevValue)
newFTab.SetValue(newIDFld,newRecNum,newRecNum)
end '-- for each i
end '-- for each aListofPoints
end '-- for each rec
'-- Add the new point shapefile to the View
newFTheme = FTheme.Make(newFTab)
theView.AddTheme(newFTheme)
newFTheme.SetVisible(true)
'-- Clean Up
newFTab.SetEditable(false)
theView.Invalidate
av.ClearMsg
av.ClearStatus
'-- End of Script: Pline2Pt.ave
Warning:
The polyline theme must have a field in the attribute table that contains the elevation values for each feature.
Note:
Spatial Analyst extension must be turned on.
Note:
You can adjust those settings if you wish.
Article ID:000004138
Get help from ArcGIS experts
Download the Esri Support App