I am currently using ArcGIS 9.1 and was referred to this
list to ask my question. I am using a python script to loop through a series
of features, select all polygons that are within 5 miles, run statistics on
those selected polygons, then append the values to a new database(dbf). I am
not sure if I am going about this correctly or not, but my script is definitely
not working. I am getting an error when it tries to append to the dbf. Here
is what I have so far. I would really appreciate any help that someone could
provide. Thanks in advance! #
--------------------------------------------------------------------------- # final_hopefully.py # Created on: Tue Aug 16 2005 04:39:33 PM # (generated by ArcGIS/ModelBuilder) #
--------------------------------------------------------------------------- # 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") gp.AddToolbox("C:/Program
Files/ArcGIS/ArcToolbox/Toolboxes/Analysis Tools.tbx") # Local variables... bgrps_data = "bgrps_data" bgrps_data__2_ = "bgrps_data" half_mile_parcels = "half_mile_parcels" bgrps_data__3_ = "bgrps_data" exported_data2_dbf = "C:\\Temp\\data2.dbf" bgrps_data__4_ = "bgrps_data" half_mile_parcels__2_ = "half_mile_parcels" exported_data1_dbf = "C:\\Temp\\data1.dbf" exported_data_dbf = "C:\\Temp\\data.dbf" exported_data_dbf__2_ = "C:\\Temp\\data.dbf" #Loop through each record gp.Workspace= "C:\\Temp\\test.mdb" # Process: Select Layer By Location (2)... gp.SelectLayerByLocation_management(bgrps_data__4_,
"WITHIN_A_DISTANCE", half_mile_parcels__2_, "26400 Feet",
"NEW_SELECTION") # Process: Summary Statistics (2)... gp.Statistics_analysis(bgrps_data__3_, exported_data2_dbf,
"AGE_PERC MEAN;home_perc MEAN", "") try: fcs = gp.listfeatureclasses() #Loop through the list of feature classes fcs.Reset() fc = fcs.Next() while fc != "": # Process: Select Layer By Location... gp.SelectLayerByLocation_management(bgrps_data__2_,
"WITHIN_A_DISTANCE", half_mile_parcels, "26400 Feet",
"NEW_SELECTION") # Process: Summary Statistics (3)... gp.Statistics_analysis(bgrps_data,
exported_data1_dbf, "AGE_PERC MEAN;home_perc MEAN", "") # Process: Append... gp.Append_management("C:\\temp\data2.dbf",
exported_data_dbf__2_, "TEST") #Move to the next fc in the list fc = fcs.Next() except: gp.addmessage(gp.getmessages(2)) print gp.getmessages(2) Michael Rose GIS Specialist The Planning Center ph. (520) 623.6146 fx. (520) 622.1950 http://www.azplanningcenter.com |
-- http://mail.python.org/mailman/listinfo/python-list