0

I am trying to write a Python script that will return the total footage of pipe for each material type. I got as far as getting the total footage for all of the pipes, I am just not sure where to go from here.

Footage = 0

with arcpy.da.SearchCursor('Pipe_Mains',['MEASUREDLE', 'MATERIAL']) as cursor:
    for row in cursor:
        Footage += row[0]

enter image description here

1

A dictionary will keep track of each material.

materials = dict()

with arcpy.da.SearchCursor('Pipe_Mains',['MEASUREDLE', 'MATERIAL']) as cursor:
    for row in cursor:
        if row[1] in materials:
            materials[row[1]] += row[0]
        else:
            materials[row[1]] = row[0]

You can then look up the footage of each material like this

materials["PL"]

will output the total footage of the material.

|improve this answer|||||
  • Thank you so much!! This works perfectly, I new to all of this so I am going have to study up on using dictionaries so I can use it in the future. – M.Welch Jun 28 '18 at 17:40
3

Try using Statistics Analysis like this:

arcpy.Statistics_analysis('Pipe_Mains','Pipe_Mains_Stats',"MEASUREDLE SUM", "MATERIAL")
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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