Select to view content in your preferred language

Dissolve Syntax (Statistics)

1679
3
12-20-2013 05:50 AM
ChrisDickerson
Deactivated User
Hey People,

I have been working on trying to perform a large dissolve analysis using statistics within my script.  I can get a simple dissolve to work with with doing statistics for one field but not multiple fields.  The resource center doesn't have any examples of using statistics for the dissolve (data management).  I need to do the dissolve a few different times but it would be a chore to manually setup 39 fields for statistics.  I am looking for a little help on syntax of my code snippet.  See the code below:

arcpy.Dissolve_management("DAT_263_49_13_wD", "A:/Projects/Location-Allocation/Final_Output/District49.shp", "N_Dist_ID", "'ORG_NO_ID COUNT';
'HIO_Total SUM';'MIO_Total SUM';'MIC_HAR SUM';'MIC_Industry SUM';'SWR_RY1 SUM';'SWR_RY2 SUM';'SWR_RY3 SUM';'Used_total SUM';'AA SUM';'AA_50k SUM';
'Core SUM';'Core_50k SUM';'Hispanic SUM';'Hispanic_50k SUM';'Women SUM';'Women_50k SUM';'Young_Adult SUM';'Young_Adult_50k SUM';'Asian SUM';
'Asian_50k SUM';'Nat_Amer SUM';'Nat_Amer_50k SUM';'Unknown SUM';'Sum SUM';'S_BMW SUM';'S_CanAM SUM';'S_Ducati SUM';'S_Honda SUM';
'S_Indian SUM';'S_Kawasaki SUM';'S_KTM SUM';'S_PGroup SUM';'S_PVictory SUM';'S_Suzuki SUM';'S_Triumph SUM';'S_Yamaha SUM';'S_T_CompDlrs SUM';'PnA_Total SUM';'GM_Total SUM'","MULTI_PART","DISSOLVE_LINES")


(added spaces for the sake of reading the code)

I have also tried just using double quote instead of single quotes and no quotes inside of the a pair of double quotes.  Let me know if this makes since and I can provide more info if needed.  Any help would be greatly appreciated, and I would be very thankful.

Chris
Tags (2)
0 Kudos
3 Replies
JoshuaChisholm
Frequent Contributor
Hello Chris

I think you have to give the fields as an array of field names. Like this:

inFC="DAT_263_49_13_wD"
outFC="A:/Projects/Location-Allocation/Final_Output/District49.shp"

dissolveFields=["N_Dist_ID","ORG_NO_ID COUNT","HIO_Total SUM","MIO_Total SUM","MIC_HAR SUM","MIC_Industry SUM","SWR_RY1 SUM","SWR_RY2 SUM","SWR_RY3 SUM","Used_total SUM","AA SUM","AA_50k SUM","Core SUM","Core_50k SUM","Hispanic SUM","Hispanic_50k SUM","Women SUM","Women_50k SUM","Young_Adult SUM","Young_Adult_50k SUM","Asian SUM"]

arcpy.Dissolve_management(inFC,outFC,dissolveFields)


Let me know if it works.
Good luck!
0 Kudos
ChrisDickerson
Deactivated User
No luck using an array. Set up the variable with the statistics and fields but got an execute error when testing in the code in the Python window.  Getting error code 000369 which is invalid input field(s). Ran just the dissolve with two fields for statistics and was still throwing the same error with the array.  This is the same error that I get when hard coding the the two fields with the statistics function as well as using an array with one field and stats function. I went back and tried my original code in the Python window and it throws the same error to.  I also check all my fields and the spelling is correct, wondering if the issue is concatenating two or more fields for the stats function.
0 Kudos
JoshuaChisholm
Frequent Contributor
That's strange Chris,

It's working on my end. Maybe you could try using the full path to the file (r"C:\Data\stuff.gdb\DAT_263_49_13_wD").

Seems like there's something wrong with the fields in your "DAT_263_49_13_wD" file. Have to tried adding a really simple field (or two) and using those?
0 Kudos