Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm new to Python but I've heard is a good way to automate tasks. I have thousands of point shapefiles and need to extract the maximum value of each one and put them in a new table. I'll appreciate your help.

share|improve this question
2  
Do you need to extract the whole record of the shapefile or just the Object ID? –  Cody Brown Jan 21 '13 at 21:24
3  
Using python to script a solution to your problem would be a fine way to go, but u should try to ask a more specific question, e.g. "I'm having trouble opening a shapefile with arcpy. Can you see where I'm going wrong with the following code snippet?" –  awesomo Jan 21 '13 at 21:35
add comment

2 Answers

Here is a quick simple way to do this:

list = [shapefile, shapefile] #enter in all of your shapefiles here in a list. You can do this with python as well.
for layer in list:
     arcpy.Statistics_analysis (layer, "out_table.dbf", [["NORTHING", "MAX"]])

UPDATE ------

list = ListFeatureClasses ("#", "Point", "C:/Database_Location")
for layer in list:
     arcpy.Statistics_analysis (layer, "out_table.dbf", [["NORTHING", "MAX"]])

This is a pretty quick and easy way to accomplish this. Hope it helps.

share|improve this answer
6  
Better yet, use ListFeatureClasses to generate the list for you. –  om_henners Jan 21 '13 at 21:54
1  
Great idea @om_henners especially if he has thousands of Dhapefiles as stated. I'll update my answer. –  Cody Brown Jan 22 '13 at 13:49
1  
Change the name of the out_table.dbf for each iteration of the loop, add a new field to this table that stores the input layer name, add the dynamically named table to a value table, and then merge the value table outside of the loop to the final table of maximum values. –  ccn Jan 22 '13 at 18:39
add comment

beside @Cody Brown Statistics_analysis, you can use max function to find maximum value of your feature.

import arcpy

workspace = "C:\Data\Test\test.shp"
recs = arcpy.SearchCursor(workspace)

ary = []

for rec in recs:
   val = rec.getValue('Distance')
   ary.append(val)

print max(ary)  

i hope it helps you...

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.