HOW TO
A Value Table is a flexible object that can be used as input for a multivalue parameter. A number of GP tools can optionally use Value Tables. For example, Union, Merge or any tool that has a multivalue parameter.
Code:
# Import system modules
import sys, string, os, win32com.client
# Create the Geoprocessor object
gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")
# Load required toolboxes...
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")
# Process: Merge...
gp.Merge_management("C:\\ESRI\\ESRIDATA\\MEX_STATES.shp;C:\\ESRI\\ESRIDATA\\USA_STATES.shp",
"C:\\ESRI\\ESRIDATA\\STATES_Merge.shp")
print "done"
Code:
# Import system modules
import sys, string, os, win32com.client
# Create the Geoprocessor object
gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")
# Set the workspace.
gp.Workspace = "C:\\ESRI\\ESRIDATA\\"
# Merge shape type, input Polyline or Polygon
shapeType = "Polygon"
gp.OverwriteOutput = 1
# Create the value table
vtab = gp.CreateObject("ValueTable")
# List all of the feature classes in the dataset
fcs = gp.ListFeatureClasses()
fcs.reset()
fc = fcs.next()
# Store all the feature classes in a value table
while fc:
# Describe the feature class
dsc = gp.Describe(fc)
if dsc.Shapetype == shapeType:
vtab.AddRow(fc)
fc = fcs.next()
# Process: Merge...
gp.Merge_management(vtab, "C:\\ESRI\\ESRIDATA\\STATES_Merge.shp")
print "done"
Code:
vtab = gp.CreateObject("ValueTable")
Code:
# Import system modules
import sys, string, os, win32com.client
# Create the Geoprocessor object
gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")
# Create the value table for the Analysis Union tool with 2 columns
vtab = gp.CreateObject("ValueTable", 2)
# Set the workspace.
gp.Workspace = "C:\\ESRI\\ESRIDATA\\"
gp.OverwriteOutput = 1
# List all of the feature classes in the dataset
fcs = gp.ListFeatureClasses()
fcs.reset()
fc = fcs.next()
while fc:
# Update the value table with a rank of 2 for each record, except MEX_STATES
if fc <> "MEX_STATES":
vtab.AddRow(fc + " " + "2")
else:
vtab.AddRow(fc + " " + "1")
fc = fcs.next()
# Union the feature classes
gp.Union_analysis(vtab, "union_out")
print "done"
Code:
# Import system modules
import sys, string, os, win32com.client
# Create the Geoprocessor object
gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")
# Create the value table for the Analysis Union tool with 2 columns
vtab = gp.CreateObject("ValueTable", 2)
# Set the workspace.
gp.Workspace = "C:\\ESRI\\ESRIDATA\\"
gp.OverwriteOutput = 1
# List all of the feature classes in the dataset
fcs = gp.ListFeatureClasses()
fcs.reset()
fc = fcs.next()
while fc:
# Update the value table with a rank of 2 for each record, except rivers
if fc <> "MEX_STATES":
vtab.AddRow("'" + fc + "'" + " " + "'2'")
else:
vtab.AddRow("'" + fc + "'" + " " + "'1'")
fc = fcs.next()
# Union the feature classes
gp.Union_analysis(vtab, "union_out")
print "done"
Code:
# Import system modules
import sys, string, os, win32com.client
# Create the Geoprocessor object
gp = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")
size = 2
# Populate the Value Table with some values
vt = gp.CreateObject("ValueTable", size)
vt.SetRow(0, "'E' 'S'")
vt.SetRow(1, "'R' 'I'")
# Read the Value Table
for i in range(vt.rowcount):
for j in range(vt.columncount):
print vt.getvalue(i, j)
Get help from ArcGIS experts
Download the Esri Support App