##Script Name: latitude of north or south limit ##Description: Extract latitude of north and south boundary of B or NB range size ##Created By: Elaine Kuo ##Date: 12/05/2012 #Import standard library modules import arcgisscripting import os #Create the Geoprocessor object gp = arcgisscripting.create(9.3) #Set the input workspace #GP.workspace = sys.argv[1] #Set the workspace. gp.Workspace= "H:/temp/test1" #Set the output workspace #outWorkspace = sys.argv[2] #Set the workspace. List all of the feature classes in the dataset 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 # Add a field to this shapefile, of type LONG gp.AddField (fc, "NorthLat", "double", 6,6) gp.AddField (fc, "SouthLat", "double", 6,6) # Make temporary featureclasses query = "\"%s\" = 'S'" % field.Name gp.Select_analysis(fc,"output.shp",query) # get latitude of north and south limits ext = gp.describe("output.shp").extent NorthLat = ext.YMax SouthLat = ext.YMin gp.CalculateField_management("output.shp", "NorthLat",str(NorthLat)) gp.CalculateField_management("output.shp", "SouthLat",str(SouthLat)) # copy temporary shapefile to fc gp.Select_analysis("output.shp",fc) # clear memory of temporary shapefile gp.Delete("output.shp") gp.AddMessage(gp.GetMessages()) print gp.GetMessages()
Solved! Go to Solution.
gp.AddField (fc, "NorthLat", "double", 6,6)
NorthLat = ext.YMax
gp.CalculateField_management("output.shp", "NorthLat",str(NorthLat))
# copy temporary shapefile to fc gp.Select_analysis("output.shp",fc)
"gp.CalculateField_management("output.shp", "NorthLat",NorthLat)
ext = gp.describe("output.shp").extent
query = "\"%s\" = 'S'" % field.Name
query = "\"C5738\" = 'S'"
query = "\"C5738\" = 'S' OR \"C9875\" = 'S'"
query = "\"C5738\" = 'S' OR \"C9875\" = 'S'"
desc = gp.describe(fc) query = "\"%s\" = 'S'" % desc.baseName
gp.AddField (fc, "NorthLat", "double", 6,6)
NorthLat = ext.YMax
gp.CalculateField_management("output.shp", "NorthLat",str(NorthLat))
# copy temporary shapefile to fc gp.Select_analysis("output.shp",fc)