<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Creating multipart polygons with ArcPy? Dissolve Failure? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625523#M48787</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is no error message. The dissolve completes, but the multiple single part features are not dissolved into a mulitpart feature class.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Aug 2015 14:43:29 GMT</pubDate>
    <dc:creator>ChadCordes</dc:creator>
    <dc:date>2015-08-25T14:43:29Z</dc:date>
    <item>
      <title>Creating multipart polygons with ArcPy? Dissolve Failure?</title>
      <link>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625517#M48781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need the functionality of the editor &amp;gt; merge command for use in a python script tool. I realize this function is not directly accessible through ArcPy, but I am hoping someone can help with a work around?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The Issue: I have a series of single part polygon features which do not touch or overlap, but have common field values. I need all these features to exist as multipart features for the random point generation to operate properly and consider all these regions equally. However, the dissolve function inconsistently fails leaving single part polygons.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Essentially, I am trying to go from single part geometries to multipart by creating feature layer selections and dissolving on that feature layer selection.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have included a code snippet below. The code works and does exactly as required, but it is inconsistent. The dissolve fails when preceded by other scripts or when significant edits with debugging have been made to other parts of this script. However, when called from a new .mxd document it runs consistently well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any advice and support would be gratefully accepted!&lt;BR /&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#Custom exceptions.
class LicenseException(Exception):
&amp;nbsp;&amp;nbsp;&amp;nbsp; pass


#Import system modules.
import arcpy
import sys
import os
import traceback
from arcpy import env
from arcpy.sa import *


#Enable geoprocessor logging.
arcpy.SetLogHistory(True)


try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; #---Check the installed ArcGIS version.---
&amp;nbsp;&amp;nbsp;&amp;nbsp; iv = arcpy.gp.GetInstallInfo()


&amp;nbsp;&amp;nbsp;&amp;nbsp; version = " ArcGIS %s : %s" % ('Version', iv.get('Version','Version Unknown'))


&amp;nbsp;&amp;nbsp;&amp;nbsp; if version.find("10.") &amp;gt; 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ArcGIS10 = True
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ArcGIS10 = False
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError("ERROR: This tool requires ArcGIS version 10.1 or greater...exiting script.")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sys.exit("")


&amp;nbsp;&amp;nbsp;&amp;nbsp; del iv, version, ArcGIS10


&amp;nbsp;&amp;nbsp;&amp;nbsp; #---Check the ArcGIS administrative license.---
&amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.CheckProduct("ArcInfo") == "AlreadyInitialized" or arcpy.CheckProduct("ArcInfo") == "Available":&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pass
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise LicenseException()


&amp;nbsp;&amp;nbsp;&amp;nbsp; #---Check out extension licenses.---
&amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.gp.CheckExtension("spatial") == "Available":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CheckOutExtension("spatial")
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError("ERROR: Spatial Analyst extension is unavailable. Please enable Spatial analyst and try again...exiting script.")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sys.exit("")


&amp;nbsp;&amp;nbsp;&amp;nbsp; #---Get tool share folder file path.---
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument("Current")
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxdpath = mxd.filePath
&amp;nbsp;&amp;nbsp;&amp;nbsp; (filepath, filename) = os.path.split(mxdpath)
&amp;nbsp;&amp;nbsp;&amp;nbsp; MCP_Path = str(filepath)


&amp;nbsp;&amp;nbsp;&amp;nbsp; #---Set the geoprocessing environment.---
&amp;nbsp;&amp;nbsp;&amp;nbsp; workspace = MCP_Path + "\OutputData\ToolOut.gdb"
&amp;nbsp;&amp;nbsp;&amp;nbsp; scratchspace = MCP_Path + "\OutputData\ScratchFolder\Scratch.gdb"


&amp;nbsp;&amp;nbsp;&amp;nbsp; env.scratchWorkspace = scratchspace
&amp;nbsp;&amp;nbsp;&amp;nbsp; env.workspace = workspace
&amp;nbsp;&amp;nbsp;&amp;nbsp; env.overwriteOutput = True


&amp;nbsp;&amp;nbsp;&amp;nbsp; #---Read user input.---
&amp;nbsp;&amp;nbsp;&amp;nbsp; BI = arcpy.GetParameterAsText(0)


&amp;nbsp;&amp;nbsp;&amp;nbsp; BIdesc = arcpy.Describe(BI) 


&amp;nbsp;&amp;nbsp;&amp;nbsp; #---Execute Reclass.---
&amp;nbsp;&amp;nbsp;&amp;nbsp; DS_RC_filename = BIdesc.name + "_DS_RC"
&amp;nbsp;&amp;nbsp;&amp;nbsp; DS_RC_out = os.path.join(workspace, DS_RC_filename)


&amp;nbsp;&amp;nbsp;&amp;nbsp; DS_Reclass = Reclassify(BI, "Value", 
&amp;nbsp;&amp;nbsp;&amp;nbsp; RemapRange([[-1000,-75,8],[-75,-50,7],[-50,-35,6],[-35,-20,5],[-20,-12,4],[-12,-6,3],[-6,-3,2],[-3,-1,1],[-1,0,"NODATA"]]), "NODATA")
&amp;nbsp;&amp;nbsp;&amp;nbsp; DS_Reclass.save(DS_RC_out)


&amp;nbsp;&amp;nbsp;&amp;nbsp; #---Execute raster to polygon conversion.---
&amp;nbsp;&amp;nbsp;&amp;nbsp; DS_Polygon_filename = BIdesc.name + "_DS_Polygon"
&amp;nbsp;&amp;nbsp;&amp;nbsp; DS_Polygon = os.path.join(workspace, DS_Polygon_filename)


&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RasterToPolygon_conversion(DS_RC_out, DS_Polygon, "SIMPLIFY", "VALUE")


&amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.Exists(DS_RC_out):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(DS_RC_out)
&amp;nbsp;&amp;nbsp;&amp;nbsp; del DS_RC_filename, DS_Polygon_filename 


&amp;nbsp;&amp;nbsp;&amp;nbsp; #---Select polygons of areas &amp;gt;= 1000m2.---
&amp;nbsp;&amp;nbsp;&amp;nbsp; DS_PS_out_filename = BIdesc.name + "_DS_PSelect"
&amp;nbsp;&amp;nbsp;&amp;nbsp; DS_PS_out = os.path.join(workspace, DS_PS_out_filename)


&amp;nbsp;&amp;nbsp;&amp;nbsp; sql = '{0} &amp;gt;= {1}'.format("Shape_Area",'1000')
&amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.Exists("DS_PS"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management("DS_PS")
&amp;nbsp;&amp;nbsp;&amp;nbsp; DS_PS = arcpy.management.MakeFeatureLayer(DS_Polygon,"DS_PS",sql)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management("DS_PS", DS_PS_out) #Done to hopefully stabilize the following selection


&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(DS_PS)
&amp;nbsp;&amp;nbsp;&amp;nbsp; del DS_PS_out_filename, sql


&amp;nbsp;&amp;nbsp;&amp;nbsp; #---------------------Perform Dissolve----------------------------------&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; DS_F_out_filename = BIdesc.name + "_DS"
&amp;nbsp;&amp;nbsp;&amp;nbsp; DS_F_out = os.path.join(workspace, DS_F_out_filename)


&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Dissolve_management(DS_PS_out,DS_F_out,"grid_code","#","MULTI_PART","DISSOLVE_LINES") 


&amp;nbsp;&amp;nbsp;&amp;nbsp; del BsMmaxS, sql


&amp;nbsp;&amp;nbsp;&amp;nbsp; #---Check to ensure dissolve function worked properly.---
&amp;nbsp;&amp;nbsp;&amp;nbsp; sql = '{0} = {1}'.format("grid_code",1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeTableView_management(DS_F_out, "DS_F_out_TV",sql)
&amp;nbsp;&amp;nbsp;&amp;nbsp; count = int(arcpy.GetCount_management("DS_F_out_TV").getOutput(0))
&amp;nbsp;&amp;nbsp;&amp;nbsp; if count &amp;gt; 1:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del sql
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.Exists(DS_F_out):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(DS_F_out)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management("DS_F_out_TV")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError("Geoprocessing Error due to memory limitations with 32bit processing. Assuming 64bit processing is unavaiable, please close your ArcMap instance, open it again and reprocess...exiting script.")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Above error prompt is my current best guess since the polygons can be quite complex and can contain many verticies. 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sys.exit("")
&amp;nbsp;&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management("DS_F_out_TV")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del sql


&amp;nbsp;&amp;nbsp;&amp;nbsp; #Continue code here..&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:39:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625517#M48781</guid>
      <dc:creator>ChadCordes</dc:creator>
      <dc:date>2021-12-12T02:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: Creating multipart polygons with ArcPy? Dissolve Failure?</title>
      <link>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625518#M48782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are the offending polygons that won't dissolve&lt;A href="http://blogs.esri.com/esri/arcgis/2010/07/23/dicing-godzillas-features-with-too-many-vertices/"&gt; godzillas?&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please&lt;A href="https://community.esri.com/migration-blogpost/1070"&gt; format your code.&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Aug 2015 23:20:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625518#M48782</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2015-08-24T23:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: Creating multipart polygons with ArcPy? Dissolve Failure?</title>
      <link>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625519#M48783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Chad, &lt;/P&gt;&lt;P&gt;I actually had to deal with something similar. I guess my main question is what progress did you make either the&amp;nbsp; &lt;A href="http://help.arcgis.com/En/Arcgisdesktop/10.0/Help/index.html#//00170000005p000000"&gt;eliminate tool&lt;/A&gt;? It sounds like that is what you want to do in the sense it might allow you to query/exclude specific fields. Is the area issue the concern? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2015 02:31:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625519#M48783</guid>
      <dc:creator>DavidWasserman</dc:creator>
      <dc:date>2015-08-25T02:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: Creating multipart polygons with ArcPy? Dissolve Failure?</title>
      <link>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625520#M48784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Curtis;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Great suggestions. However, I just checked the polygons and they're not godzillas. I just got a failure from a dissolve with vertex counts ranging from 30 to 120.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2015 14:36:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625520#M48784</guid>
      <dc:creator>ChadCordes</dc:creator>
      <dc:date>2015-08-25T14:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: Creating multipart polygons with ArcPy? Dissolve Failure?</title>
      <link>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625521#M48785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is the specific error message, can you post it please?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2015 14:41:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625521#M48785</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-08-25T14:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Creating multipart polygons with ArcPy? Dissolve Failure?</title>
      <link>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625522#M48786</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No the area issue is not the concern. The issue is I am trying to create multipart polygons from a series of single part features using ArcPy. The operation is similar to that performed with the editor &amp;gt; merge functionality. This however is not supported with ArcPy. I have found a work around by using feature layer selections and then dissolving on a given field, but the dissolve function is inconsistently failing for some unknown reason. It primarily fails when it has been preceded by other scripts, or when significant modifications have been made to other lines of code within the script which calls the dissolve function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I appreciate the suggestion with the eliminate tool, but I don't think that will solve my problem. Thanks though.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2015 14:41:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625522#M48786</guid>
      <dc:creator>ChadCordes</dc:creator>
      <dc:date>2015-08-25T14:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: Creating multipart polygons with ArcPy? Dissolve Failure?</title>
      <link>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625523#M48787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is no error message. The dissolve completes, but the multiple single part features are not dissolved into a mulitpart feature class.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2015 14:43:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625523#M48787</guid>
      <dc:creator>ChadCordes</dc:creator>
      <dc:date>2015-08-25T14:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: Creating multipart polygons with ArcPy? Dissolve Failure?</title>
      <link>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625524#M48788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;From a purely Python programming perspective, having 100+ lines of code within a single try block is unusual.&amp;nbsp; What does your except clause look like?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2015 15:14:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625524#M48788</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-08-25T15:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: Creating multipart polygons with ArcPy? Dissolve Failure?</title>
      <link>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625525#M48789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Granted it is a large script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#---Exception handling.---
except SystemExit:
&amp;nbsp; pass

except KeyboardInterrupt:
&amp;nbsp; arcpy.AddMessage("Interruption requested...exiting script")

except arcpy.ExecuteError:
&amp;nbsp; msgs = arcpy.GetMessages(2)
&amp;nbsp; arcpy.AddError(msgs)

except LicenseException:
&amp;nbsp; arcpy.AddError("ERROR: The BsM 2015 Map Creation Package requires the ArcGIS Advanced(ArcInfo) license. Please see your ArcGIS License Administrator...exiting script.")

except:
&amp;nbsp; tb = sys.exc_info()[2]
&amp;nbsp; tbinfo = traceback.format_tb(tb)[0]
&amp;nbsp; pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
&amp;nbsp; msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
&amp;nbsp; arcpy.AddError(msgs)
&amp;nbsp; arcpy.AddError(pymsg)

&amp;nbsp; if arcpy.Exists(DS_F_out):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(DS_F_out)

finally:
&amp;nbsp; #Clean.
&amp;nbsp; if arcpy.Exists(DS_Polygon):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(DS_Polygon)
&amp;nbsp; if arcpy.Exists(DS_PS_out):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(DS_PS_out)

&amp;nbsp; #Check In Extensions.
&amp;nbsp; arcpy.CheckInExtension("spatial")

&amp;nbsp; #Refresh the Table of Contents and Active View windows.
&amp;nbsp; arcpy.RefreshTOC()
&amp;nbsp; arcpy.RefreshActiveView()

&amp;nbsp; #---Include text to improve batch process result readability.---
&amp;nbsp; arcpy.AddMessage("\n")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:39:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625525#M48789</guid>
      <dc:creator>ChadCordes</dc:creator>
      <dc:date>2021-12-12T02:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: Creating multipart polygons with ArcPy? Dissolve Failure?</title>
      <link>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625526#M48790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you run the code two or three times in a row using the same dataset, does it work each time or only the first time?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2015 18:48:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625526#M48790</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-08-25T18:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: Creating multipart polygons with ArcPy? Dissolve Failure?</title>
      <link>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625527#M48791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It runs flawlessly each time. &lt;BR /&gt;In fact, it runs flawlessly no matter what raster dataset is input at the top of the script.&lt;/P&gt;&lt;P&gt;The problem only arises when I run the 2 script tools which precede this one. They're used to create the raster which is input in this script.&lt;/P&gt;&lt;P&gt;However, they also run flawlessly, are very stable, and seem to be bug free.&lt;/P&gt;&lt;P&gt;Once the tool errors, it will continue to error unless I close the .mxd and reopen it. Then it will run smoothly again.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The only other time the dissolve fails is when I make edits/debug this tool.&lt;/P&gt;&lt;P&gt;Once the logic is correct. The dissolve will continue to fail until I restart the .mxd.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2015 19:09:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625527#M48791</guid>
      <dc:creator>ChadCordes</dc:creator>
      <dc:date>2015-08-25T19:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: Creating multipart polygons with ArcPy? Dissolve Failure?</title>
      <link>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625528#M48792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am seeing a similar deal with Dissolve run at the end of a large script. The dissolve works fine from ArcMap and run from a clean Python session with similar environment. Here is my error message:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;21:18:53 43.63 Dissolve
ERROR: File "Q:\tools\nhr_raster\HRStepL.py", line 1160, in RasterProc
&amp;nbsp;&amp;nbsp;&amp;nbsp; "OBJECTID COUNT", "MULTI_PART")
Executing: Dissolve lyrCat C:\Working\StepL_0604_20151123\work.gdb\vpucat_poly1 GRIDCODE "OBJECTID COUNT" MULTI_PART DISSOLVE_LINES
Start Time: Mon Nov 23 21:18:56 2015
Sorting Attributes...
Dissolving...
ERROR 999999: Error executing function.
ERROR: Invalid Topology [Cannot open cache file.]
ERROR: Failed to execute (Dissolve).
Failed at Tue Nov 24 01:23:57 2015 (Elapsed Time: 4 hours 5 minutes 1 seconds)&lt;/PRE&gt;&lt;P&gt;Here's what happens when run from a straight Python command line:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Executing: Dissolve C:\Working\StepL_0604_20151123\work.gdb\vpucat_poly0 C:\Working\StepL_0604_20151123\work.gdb\vpucat_poly0a Grid
ode "objectid count" MULTI_PART DISSOLVE_LINES
Start Time: Tue Nov 24 10:27:58 2015
Sorting Attributes...
Dissolving...
Succeeded at Tue Nov 24 10:30:09 2015 (Elapsed Time: 2 minutes 11 seconds)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have set ARCTMPDIR to a writeable folder&lt;A href="http://support.esri.com/en/knowledgebase/techarticles/detail/29559" rel="nofollow noopener noreferrer" target="_blank"&gt; (Esri KB 25995)&lt;/A&gt; and have even tried running half the polygons and get the same behavior. Given how things are hanging before they crash i suspect there is a resource issue here (ie lack of RAM) and that things eventually time out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't get the problem (I don't think) when running 64 bit, which is even more evidence that this is a resources issue. (Along with your experience that restarting the mxd lets it work - restarting the mxd would clear layers and other cruft from memory.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am going to go back and try deleting some layers from memory in the hope that will solve my problem. My scripts &lt;A href="https://community.esri.com/message/422452" target="_blank"&gt;clean up memory in a finally block&lt;/A&gt; but I think there is enough stuff in this script that I need to do some pre-cleanup!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm also going to try to add some &lt;A href="http://stackoverflow.com/questions/4484167/details-how-python-garbage-collection-works" rel="nofollow noopener noreferrer" target="_blank"&gt;garbage collection&lt;/A&gt; to hopefully release some memory that Python may be holding onto. Garbage collection happens automatically but a complicated script may benefit from a gc.collect() before the max possible memory may be needed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import gc
gc.collect()&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;UPDATE: &lt;/STRONG&gt;I've started an incident with Esri support and they pretty much told me that Dissolve is not stable with really large inputs (my input that was failing is a Raster To Polygon output of Watershed() output with about 70,000 polygons). The workaround is to tile the data and dissolve smaller datasets, or run in x64 python (for example, x64 background processing). (Not an option for me, unfortunately.)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:39:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625528#M48792</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-12T02:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: Creating multipart polygons with ArcPy? Dissolve Failure?</title>
      <link>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625529#M48793</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Curtis,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Recently, I've ran into the same problem in try to handle multiple overlapping buffers and dissolving into a multipart feature.&amp;nbsp; The only solution I found to work was to depart from arcpy and use these python libraries noted on this page: &lt;A href="http://www.macwright.org/2012/10/31/gis-with-python-shapely-fiona.html" title="http://www.macwright.org/2012/10/31/gis-with-python-shapely-fiona.html"&gt;GIS with Python, Shapely, and Fiona - macwright.org&lt;/A&gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After making the modifications for my Windows based python, I was able to use the union example to create the feature I needed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Nov 2015 14:20:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625529#M48793</guid>
      <dc:creator>DanielThomas1</dc:creator>
      <dc:date>2015-11-30T14:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: Creating multipart polygons with ArcPy? Dissolve Failure?</title>
      <link>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625530#M48794</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I misunderstood then. Thanks for the clarification. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Nov 2015 18:10:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625530#M48794</guid>
      <dc:creator>DavidWasserman</dc:creator>
      <dc:date>2015-11-30T18:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: Creating multipart polygons with ArcPy? Dissolve Failure?</title>
      <link>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625531#M48795</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Curtis,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This essentially turned out to be the culprit. The ESRI support people took almost a month working with me to understand then sort out the issue. Their solution was always to just use a 64bit processing environment; or as a work around, restart the map document as I was doing. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Apparently there was some mysterious behind the scenes virtual memory cache (they never really explained this too well) which was becoming overloaded. The script tool which I was running before the dissolve created a DEM. This was loading up the cache. Then when I would run the script tool which called the dissolve geoprocess (which itself has a very high virtual memory requirement) overloaded the cache. This doesn't make a whole ton of sense because from what I understand all virtual memory caches are cleared when a tool is closed. Anyway, it really only poses an issue when working within a 32bit OS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Little late now, but just thought I'd follow up. Thanks for your effort!&lt;BR /&gt;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Jan 2016 01:14:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/creating-multipart-polygons-with-arcpy-dissolve/m-p/625531#M48795</guid>
      <dc:creator>ChadCordes</dc:creator>
      <dc:date>2016-01-08T01:14:41Z</dc:date>
    </item>
  </channel>
</rss>

