Select to view content in your preferred language

Python Dissolve tool - How to define Statistic type?

7289
2
Jump to solution
03-23-2013 03:20 PM
PatriciaAlexandre
New Contributor
I'm trying to dissolve a polygon shapefile using python.

I want to dissolve the polygons using the field "COUNTY" AND I want to sum the housing units (field HU00) per County.
I wrote this:

arcpy.Dissolve_management("co_blk00_PLA", "co_blk00_dissolve","COUNTY",["HU00","SUM"],"MULTI_PART")

The python window says there's no syntax errors, but when I try to run it the error is:

"untime error <class 'arcgisscripting.ExecuteError'>: ERROR 000487: Statistic method is empty"

So how do I define the statistic method? I've tried several things and nothing works. Help!
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
curtvprice
MVP Alum
Let me give you some generic advice rather than just provide an answer. The conversion of tool input to Python syntax is sometimes quite complicated, and many tools are quite different, depending on the parameters.

The easiest way to get a Python syntax to do what you want is to


  1. Run the tool interactively

  2. Go to the Geoprocessing > Results , right click the completed tool run, and pick "Copy Python Snippet"

  3. Paste in to your code and edit in your input variables into what was pasted.

After that, hopefully the tool reference / help will have examples for most exceedingly complex operations (example: Calculate Field Examples in the help).

View solution in original post

2 Replies
curtvprice
MVP Alum
Let me give you some generic advice rather than just provide an answer. The conversion of tool input to Python syntax is sometimes quite complicated, and many tools are quite different, depending on the parameters.

The easiest way to get a Python syntax to do what you want is to


  1. Run the tool interactively

  2. Go to the Geoprocessing > Results , right click the completed tool run, and pick "Copy Python Snippet"

  3. Paste in to your code and edit in your input variables into what was pasted.

After that, hopefully the tool reference / help will have examples for most exceedingly complex operations (example: Calculate Field Examples in the help).
PatriciaAlexandre
New Contributor
Dear curtvprice,

Your answer was really helpful!!! I solved my problem!

arcpy.Dissolve_management("co_blk00_PLA","V:/Data/Housing/Chp4/dissolve_test.shp","COUNTY00","HU00 SUM","MULTI_PART","DISSOLVE_LINES")

It was as simply as adding a space after the field I wanted to sum before I closed the quotes. The most unbelievable thing was that I could not find any example on line. I loved your solution, though. Simple and elegant! Also, it will help me with another tool I was having problems with. The "Spatial join"

The tool "Add join" from the arctoolbos is different from what you do when you right click a layer and join, join based on spatial location. So now I know what to do to see the python code!

Thanks!! 



Let me give you some generic advice rather than just provide an answer. The conversion of tool input to Python syntax is sometimes quite complicated, and many tools are quite different, depending on the parameters.

The easiest way to get a Python syntax to do what you want is to


  1. Run the tool interactively

  2. Go to the Geoprocessing > Results , right click the completed tool run, and pick "Copy Python Snippet"

  3. Paste in to your code and edit in your input variables into what was pasted.


After that, hopefully the tool reference / help will have examples for most exceedingly complex operations (example: Calculate Field Examples in the help).
0 Kudos