[Tutor] Help needed with script to batch-create shapefiles
lgxjcb at nottingham.ac.uk
Wed Feb 16 22:37:10 CET 2005
I have several thousand files in dBaseIV format that I need to convert to shapefiles for use in ArcGIS. I've written a script (see below) to automate this process but thus far have been unable to get it to work. I suspect that there's a simple reason for this, but I'm a complete novice with Python and have been unable to find it.
Any help would be greatly appreciated!
##Script Name: dBase Table to Shapefile
##Description: Converts dBase files to shapefiles
##Created By: Chris Bromley.
# 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/Conversion Tools.tbx")
gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")
#Define & create variables to contain the source files and output file location paths
gp.workspace = "C:\PhD\ElwhaRiverProject\Physical_modelling\Model_Data_Corrected\Tester3\One"
out_workspace = "C:\PhD\ElwhaRiverProject\Physical_modelling\Model_Data_Corrected\Tester3"
# Get a list of the dBase tables in the workspace
fcs = gp.ListTables("*","dBase")
# Loop through the list of feature classes
fc = fcs.next()
# Set the output filename for each output to be the same as the input filename
output = out_workspace + fc
# Process: Make XY Event Layer...
gp.MakeXYEventLayer_management(fc, "x", "y", output, "")
# Process: Feature Class To Shapefile (multiple)...
gp.FeatureClassToShapefile_conversion(output, out_workspace, )
fc = fcs.next()
This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.
More information about the Tutor