Dissolve Not Working in Python Only in ModelBuilder

1039
7
08-18-2016 09:37 AM
TiffanySelvidge1
Occasional Contributor III

I am using ArcGIS 10.3.1 on my local and 10.4 on the server.

I constructed a model that at one point appends 2 layers and then dissolves the data. The append accurately appends data from both layers but the dissolve only contains data from one layer. I have this same process in 4 other models and it works for those but not this one. This process does work when I run it in modelbuilder. My python script was exported directly from the working module. I have compared the script against the working scripts and can find no difference in the procedures.

For Example (Cliff Notes Version):

LayerNew: New data that was just buffered

LayerOld: Old data buffered that needs to be updated

Append LayerNew with LayerOld. Outcome is LayerOld containing data from LayerOld and LayerNew.

Dissolve LayerOld. Outcome is only data from LayerNew.

In Python: 

# Process: Buffer
arcpy.Buffer_analysis(GeoRecsNew_AllBuff_NS__2_, ServerConnection_GeoRecsNewBuff_NoNulls_Sym_NS, "1 Miles", "FULL", "ROUND", "LIST", "FileID;WorkStatus;Subs_new;Subs_Current;Subs_Finished;DateAdded_month;NodeDissolved;LotCount_Finished", "PLANAR")
print ("buffer")


# Process: Append
arcpy.Append_management("'Database Connections\\ServerConnection\\ServerFolder\\ServerConnection.GeoRecsNewBuff_NoNulls_Sym_NS'", ServerConnection_GeoRecsOldBuff_NoNulls_Sym_NS, "TEST", "", "")
print ("append buffers")


# Process: Dissolve
arcpy.Dissolve_management(ServerConnection_GeoRecsOldBuff_NoNulls_Sym_NS__2_, ServerConnection_GeoRecsOldBuff_SymDissolve_NS, "FileID;WorkStatus;Subs_new;Subs_Current;Subs_Finished;DateAdded_month;NodeDissolved;LotCount_Finished", "", "MULTI_PART", "DISSOLVE_LINES")
print ("dissolve buffers")

In ModelBuilder:

0 Kudos
7 Replies
Robert_LeClair
Esri Frequent Contributor

What error code does the Python script give you?

0 Kudos
TiffanySelvidge1
Occasional Contributor III

It does not give me an error. I only find out the layer is missing all the prior data when I check it in sql server or arcmap.

0 Kudos
DarrenWiens2
MVP Honored Contributor

Double-check your layer names/variables (we can't see that part of your script):

ServerConnection_GeoRecsOldBuff_NoNulls_Sym_NS

vs.

ServerConnection_GeoRecsOldBuff_NoNulls_Sym_NS__2_

TiffanySelvidge1
Occasional Contributor III

The connections match up and are what they are supposed to be.  It is very confusing.

0 Kudos
DarrenWiens2
MVP Honored Contributor

Okay, it's just that the picture of your model shows Append flowing into Dissolve, but unless your two layer name variables are equal, that's not what your script is doing.

Also, the path in the Append tool is enclosed by double, then single quotes, which is non-standard. I'm not sure if that causes any problems, just not sure why it was interpreted that way.

TiffanySelvidge1
Occasional Contributor III

I will modify the code to reflect both variables. I am not sure why modelbuilder extracts the code into python like that. The setup is the same in the other codes that are working; ie. only showing one layer name but since python apparently has something against these particular layers, it is definitely worth trying.

Same goes for the quotes. I didn't realize that was non-standard and will change them. 

Thanks!

0 Kudos
TiffanySelvidge1
Occasional Contributor III

I changed the code to reflect both layers and modified the quotes as only doubles but the outcome was still the same as before. As a go-around, I added in a copy feature layer after the append and then dissolved the copied layer. It is an extra step but it works and results in all the data existing in the dissolved layer.

I still don't know why it is only this particular job that has the problem and not the other 3 I have developed. It is very odd. 

Thanks again for your help!

0 Kudos