1

In an arcpy script, I run a Union on a list of geometry objects. The output is set to an empty geometry object. The Union runs fine. What I am trying to do is then feed that output into the Dissolve tool. No matter how I format the input, I get the following error:

Parameters are not valid. ERROR 000732: Input Features: Dataset in_memory\f8537CACB_AB51_4BDC_B8E7_0895F11E6AF0 does not exist or is not supported

ESRI help files indicate that tools set to output to an empty geometry object return a list of geometry objects. The output from the Union tool gives <Geometry object at 0x26d25910[0x27397068]> when queried with repr(). I have tried putting the Union result directly into the Dissolve tool and likewise the 0 index item from the result, seeing as it supposed to be a list. Both result in an error, the latter saying that a geometry object is not indexable. Here is a code snippet:

if len(lstHSGeoms) > 1:
 #Union geometries into one geometry
 lstHSUnionGeom = arcpy.Geometry()
 arcpy.Union_analysis(lstHSGeoms, lstHSUnionGeom, "ONLY_FID")
 arcpy.AddMessage(' lstHSUnionGeom: %s' % repr(lstHSUnionGeom))
 lstHSOneGeom = arcpy.Geometry()
 arcpy.Dissolve_management(lstHSUnionGeom,lstHSOneGeom, None, None, "SINGLE_PART")
 hsOneGeom = lstHSOneGeom[0]

The list lstHSGeoms is a Python list of polygon geometries, which have checked out as valid. The Union runs, but the Dissovle doesn't. I'm stymied. BTW, I tried using an empty string for the fourth parameter of Dissolve (seeing that it is supposed to be a string type), but it didn't make a difference.

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Sep 10, 2012 at 19:55

1 Answer 1

5

Setting the output of a geoprocessing tool to an emtpy arcpy.geometry object is not the standard method for using in-memory workspaces. Instead, you want to set the output of the Union to a string variable that references the "file name" of the in-memory feature dataset, almost exactly as if you were using a shapefile. The only difference is that instead of setting your variable to C:\temp\lstHSUnionGeom.shp you would use in_memory\lstHSUnionGeom. Here's the updated code:

if len(lstHSGeoms) > 1:
 #Union geometries into one geometry
 lstHSUnionGeom = "in_memory\\lstHSUnionGeom" #Two slashes required due to escape character
 arcpy.Union_analysis(lstHSGeoms, lstHSUnionGeom, "ONLY_FID")
 arcpy.AddMessage(' lstHSUnionGeom: %s' % repr(lstHSUnionGeom))
 lstHSOneGeom = "in_memory\\lstHSOneGeom" #Two slashes required due to escape character
 arcpy.Dissolve_management(lstHSUnionGeom,lstHSOneGeom, None, None, "SINGLE_PART")
answered Sep 10, 2012 at 21:06
5
  • Well, now, new tricks for an old dog. Thank you ever so kindly @dmahr. I shall keep this new knowledge in my hip pocket at the ready. In the present case, I tried your suggested code update, but it didn't work. I have tried several other variations that I could think of, but none of them have worked. I think the problem may be that I am working with geometries not features. I'm also working in 10.0, which may in itself be a problem. I simply want to be able to use geometry objects -- instead of features -- with geoprocessing tools ... like I'm supposed to be able to. Additional ideas? Commented Sep 11, 2012 at 1:20
  • Sure thing! Now, when you say it didn't work, did it throw any errors? Did you try the exact same code, but writing the Union output to shapefiles to see if the issue is caused by something else? With ArcGIS and ArcPy as finnicky as they are, it's best to walk through the unknown parts of your code step-by-step to figure out where stuff is going wrong. Commented Sep 11, 2012 at 1:26
  • Thanks again @dmahr. To answer your questions: (1) Yes, it did throw errors. It didn't like the setting of the in_memory path before using it as the output in the tool. It is just seen as a plain string, not a path name. Entering the in memory paths directly in the tool, seems to have worked or at least no errors were thrown; (2) No, I haven't output things to shapefiles, because I have only geometry objects, not features at this point. I very well may do this in the course of further troubleshooting. I now have a related question that I will post separately in just a bit. Commented Sep 11, 2012 at 2:18
  • Find the above mentioned related question, now posted. Commented Sep 11, 2012 at 3:03
  • I did try writing the Union output to a shapefile and found that the geometry was invalid. So, there is something wrong with the Union output after all. When I get the chance tomorrow I will try taking the geometries from the original Python list and putting them into a shapefile. Then I'll dissolve those and read the geometry of the Dissolve result. I don't want to have to do that, but if it works ... Commented Sep 11, 2012 at 4:23

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.