Hi Elaine,I helped you I hope with your last question, and maybe I can help further. Not sure how much experience with python you have, but what do you say we get started? I didn't offer any code before, but now that we're being more specific, let us see where that goes, okay? First, I am not sure what you mean about 'merging' but it may be possible to do what you ask in a single cursor pass. Am I on the right track to assume you need a table classifying your each of your shapefiles via some number CXXX? I will need more info please.Did you know you can with arcpy.env.workspace set to your directory of shapefiles use the listfeatureclasses command to acquire a list to iterate over and perform processing pertaining to each?...that would be where I would found my start on a approach for assimilating lot/long vals by your determined type.
##Script Name: Add rows ##Description: Add one row ##Created By: Elaine Kuo ##Date: 12/24/2012 #Import standard library modules import arcgisscripting import os #Create the Geoprocessor object gp = arcgisscripting.create(9.3) #Set the input workspace gp.Workspace= "H:/temp/test" #Set the output workspace outWorkspace= "H:/temp" #Get a list of the featureclasses in the input folder fcs = gp.ListFeatureClasses() # Loop through every item in the list that was just generated for fc in fcs: # Break out the name, no path or extension, using the describe object. desc = gp.describe(fc) featureName = desc.name # Make featureclasses as layers gp.OverWriteOutput = 1 gp.toolbox = "Data Management" gp.MakeFeatureLayer(fc,"lyr") #Get a list of the fields in the featureclass fields = gp.ListFields("lyr", "C*", "String") # Loop through every item in the list that was just generated for field in fields: # Create the insert cursor and a new empty row rowsNew = gp.InsertCursor("lyr") rowNew = rowsNew.newRow() # Populate attributes of new row rowNew.setValue("ausarea_km", 0) # Insert the new row into the shapefile rowsNew.insertRow(rowNew) # Clean up the cursor del rowsNew # clear memory of layers gp.Delete("lyr")
That's a little confusing. You have mostly empty shapefiles? And you want to add fields to a single shapefile so that you have string fields added, C0001 - C0100. ...and then C0101 - C0150 in another? Here's the thing: you can easily add fields without bothering to merge feature classes that have no records. Is that what you want? Do you need to load any points? You mentioned that you had single points for each 101 to 150, no need to save these?...you are mainly interested in the schema or file structure?
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.