#Import modules import arcgisscripting, sys, os gp = arcgisscripting.create(9.3) gp.workspace = "F:\geodata2009\africa\catalogues/DD.mdb" gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Conversion Tools.tbx") gp.AddToolbox("C:/Program Files/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx") # Local variables... data_digger = "F:\\geodata2009\\africa\\catalogues\\DD.mdb\\Data" # Set a variable to store the updated feature class # Local variables... dd_polys_shp = "F:\\scratchdisk\\dd_polys.shp" # Create an Array object. # vertex_array = gp.createobject("Array") # Process: Get Count... record_count = gp.GetCount_management(data_digger) count = int(record_count.GetOutput(0)) print count n = 0 searchCursor = gp.SearchCursor(data_digger) newRow = searchCursor.Next() # we are stepping through the Access table record by record while newRow <> None: ulx = newRow.GetValue("ULX") uly = newRow.GetValue("ULY") lrx = newRow.GetValue("LRX") lry = newRow.GetValue("LRY") # clear the array ready for next time vertex_array.RemoveAll() # List of coordinates. # coordList = [str(ulx)+";"+str(lry),str(ulx)+";"+str(uly),str(lrx)+";"+str(uly),str(lrx)+";"+str(lry)] # For each coordinate set, create a point object and add the x- and # y-coordinates to the point object, then add the point object # to the array object. # for coordPair in coordList: pnt = gp.createobject("Point") x, y = coordPair.split(";") try: pnt.x = x pnt.y = y vertex_array.add(pnt) # Create a polygon geometry object using the array object # created from the coordinate list above. # polyGeom = gp.createobject("geometry", "polygon", vertex_array) except: print 'non numeric or null data value encountered, skipping...' pass try: # add new cursor to the shapefile insert_cur = gp.InsertCursor(dd_polys_shp) new_feature = insert_cur.newRow() new_feature.shape = polyGeom # Data_ID field contains the unique ID to perform later joins on data_id = newRow.GetValue("Data_ID") new_feature.setValue ("Data_ID", data_id) insert_cur.InsertRow(new_feature) except: print 'no record added this time' pass print n n = n + 1 newRow = searchCursor.Next()