HOW TO

Convert a polyline theme to a GRID

Last Published: April 25, 2020

Summary

You can use ArcView Spatial Analyst to convert a polyline theme that contains contour elevations into a floating point elevation GRID theme.

Procedure

You cannot interpolate a new surface based on a polyline theme. Interpolating a surface only works for a point theme. To accomplish this task you must first convert the polyline theme to a point theme, then perform the interpolation.

  1. Open a new script window.

    A. Activate the Project window.
    B. Click the Scripts icon.
    C. Click New.

  2. Copy the following code into the script window:

    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.

  3. Attach the script to a button on the View GUI.

    A. Compile the script.
    B. Switch to the Project window.
    C. Select Customize from the Project menu.
    D. On the Customize dialog box, click the Type dropdown arrow and click View.
    E. Select Buttons under Category.
    F. Click the New button.
    G. Double-click the Click property in the Customize dialog box.
    H. Type the name of the script in the Script Manager and click Select.
    I. Close the Customize dialog box.

    For more information, see "Customize dialog box" in ArcView Help.


  4. Make the polyline theme active.
  5. Click the new button to run the script.
  6. Select the field that contains the elevation value. A new point theme will be added to the view.
  7. Make the point theme active.
  8. Select Interpolate Grid from the Surface menu.

    Note:
    Spatial Analyst extension must be turned on.

  9. Specify Output Grid Extent to Same as <shapefile>.
  10. Accept the default settings for the remaining windows.

    Note:
    You can adjust those settings if you wish.

  11. Specify the following in the Interpolate Surface window:

    · Method: Spline
    · Z Value Field: Elev
    · Weight: 0.1
    · No. of Points: 12
    · Type: Tension

  12. Click OK.

Article ID:000004138

Software:
  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic