Feature to Polygon in existing layer

521
2
03-20-2012 11:24 AM
Zeke
by
Regular Contributor III
Now that my generic python question has been answered (thanks again!), I have a specific arcpy question, which may have a generic quality as well.

I frequently use the Construct Polygons tool to create parcel polygons out of line features I've created. The polygons are created in an existing feature class. That works great. But I can't figure out how to duplicate this behavior (polygons added to an existing file) in a script. The closest I can come is using Feature to Polygon, which does create the polygons, but in a new feature class. I suppose I could then copy the new polygons to the existing table and delete the created one, but this seems like an extra step compared to the Topology toolbar tool. I know some other tools on the toolbar work this way compared to their toolbox equivalents also. Is there a function I'm missing, or is this just the way it is? Thanks.

import arcpy

lineFeature = arcpy.GetParameterAsText(0)
polygonFeature = arcpy.GetParameterAsText(1)

arcpy.FeatureToPolygon_management(lineFeature, polygonFeature, "", "NO_ATTRIBUTES", "")
Tags (2)
0 Kudos
2 Replies
DarrenWiens2
MVP Honored Contributor
I don't know of any way to circumvent the "convert->append->delete" workflow, but if you're doing this on a small number of line features numerous times and have the need for speed, you might want to look into using the "in_memory" workspace (probably my favourite ArcGIS secret).

import arcpy

lineFeature = "H:/GIS_Data/TEMP.gdb/lines"
intPoly = "in_memory/intpoly"
polygonFeature = "H:/GIS_Data/TEMP.gdb/poly"

arcpy.FeatureToPolygon_management(lineFeature, intPoly, "", "NO_ATTRIBUTES", "")
arcpy.Append_management(intPoly, polygonFeature, "NO_TEST")
arcpy.Delete_management(intPoly)
0 Kudos
Zeke
by
Regular Contributor III
Hmm, well, ok. I know many GIS tasks require multiple steps, just thought that since there are toolbar tools that can create in an existing feature class, they would be available through arcpy. Who knows, maybe the toolbar methods use the same method with an intermediate temp feature class behind the scenes.
I'm trying to create more automated procedures for coworkers that don't know much ArcGIS. The less actual editing they have to do, the better for all of us.
Thanks for the in_memory info, I'll check that out.
0 Kudos