<?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 ArcPy: Feature to Polygon (in_memory) in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-feature-to-polygon-in-memory/m-p/412894#M32494</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've created a python scripts that takes a feature class (polyline) of contours and a feature class (polyline) that represents the position of a proposed dam wall. I then use the feature to polygon tool to create a polygon from each contour that represents the proposed full supply level of the proposed dam site. I then use Polygon Volume Tool to determine the volume and surface area for each proposed full supply level.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem that I'm having is that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;if I use in_memory for the output for feature to polygon, the shape_length &amp;amp; shape_area is missing&lt;/LI&gt;&lt;LI&gt;if I save the output for each polygon from Feature to Polygon , the shape_length &amp;amp; shape_area is added, but when I try to append the following feature classes into a new feature class using an Insert Cursor, the geometry is not being transferred into the empty feature class.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From the testing that I've done there seems to be a problem in storing the output feature class from Feature to Polygon in_memory as the shape_length &amp;amp; shape_area fields are being dropped, which I tested within ArcMap running the tool and storing the output into memory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've also tested the same tools using the same input layers and saved the results to disk, the shape_length and shape_area are then preserved within the output results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If anyone can give me advice in how to resolve the following, it would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;'''
Created on May 28, 2015
@author: PeterW
The following script calculates the volume for each Full Supply Level
to calculate the capacity curve for a proposed dam site
'''
# import system modules and site packages
import arcpy
# Check out 3D Analyst
arcpy.CheckOutExtension("3D")
# set environment settings
arcpy.env.overwriteOutput = True
# set input and output arguments
cont_line = r"F:\Projects\2015\PRCPTWAT02\13176\A34631\wspace\ChrisFox.gdb\Contours"
dw_line = r"F:\Projects\2015\PRCPTWAT02\13176\A34631\wspace\ChrisFox.gdb\Dam_Wall"
fsl_gon = r"F:\Projects\2015\PRCPTWAT02\13176\A34631\wspace\ChrisFox.gdb\Full_Supply_Level"
surf = r"F:\Projects\2015\PRCPTWAT02\13176\A34631\wspace\TIN\tin"
# make feature layer from the dam wall (polyline)
dwLyr = arcpy.MakeFeatureLayer_management(dw_line,"dwLayer")
# convert each FSL contour polyline into a FSL polygon and determine the volume
# below the contour elevation using the polygon volume tool
with arcpy.da.SearchCursor(cont_line,["Elevation"]) as cursor: &lt;A href="mailto:#@UndefinedVariable" rel="nofollow noopener noreferrer" target="_blank"&gt;#@UndefinedVariable&lt;/A&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elev = str(row[0])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outName = "FSL" + elev + "m"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sqlExp = "Elevation" + " = " + elev
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contLyr = arcpy.MakeFeatureLayer_management(cont_line, outName, sqlExp)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fslLyr = "in_memory" + "\\" + outName
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.FeatureToPolygon_management([contLyr,dwLyr], fslLyr, attributes = True)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(fslLyr, "Elevation", "SHORT")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(fslLyr, "Elevation", elev, "PYTHON_9.3")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fields = arcpy.ListFields(fslLyr)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fields = [field.name for field in fields]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print fields
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.SearchCursor(fslLyr, fields) as sCur: &lt;A href="mailto:#@UndefinedVariable" rel="nofollow noopener noreferrer" target="_blank"&gt;#@UndefinedVariable&lt;/A&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.InsertCursor(fsl_gon, fields) as iCur: &lt;A href="mailto:#@UndefinedVariable" rel="nofollow noopener noreferrer" target="_blank"&gt;#@UndefinedVariable&lt;/A&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for sRow in sCur:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; iCur.insertRow(sRow)

# calculate the volume and surface area for each Full Supply Level polygon and the TIN 
arcpy.PolygonVolume_3d(surf, fsl_gon, "Elevation", "BELOW", "SVolume", "SArea","0")

# print statement that process is completed
arcpy.AddMessage("Completed Processing Capacity Curves")&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter Wilson&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 18:44:12 GMT</pubDate>
    <dc:creator>PeterWilson</dc:creator>
    <dc:date>2021-12-11T18:44:12Z</dc:date>
    <item>
      <title>ArcPy: Feature to Polygon (in_memory)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-feature-to-polygon-in-memory/m-p/412894#M32494</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've created a python scripts that takes a feature class (polyline) of contours and a feature class (polyline) that represents the position of a proposed dam wall. I then use the feature to polygon tool to create a polygon from each contour that represents the proposed full supply level of the proposed dam site. I then use Polygon Volume Tool to determine the volume and surface area for each proposed full supply level.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem that I'm having is that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;if I use in_memory for the output for feature to polygon, the shape_length &amp;amp; shape_area is missing&lt;/LI&gt;&lt;LI&gt;if I save the output for each polygon from Feature to Polygon , the shape_length &amp;amp; shape_area is added, but when I try to append the following feature classes into a new feature class using an Insert Cursor, the geometry is not being transferred into the empty feature class.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;From the testing that I've done there seems to be a problem in storing the output feature class from Feature to Polygon in_memory as the shape_length &amp;amp; shape_area fields are being dropped, which I tested within ArcMap running the tool and storing the output into memory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've also tested the same tools using the same input layers and saved the results to disk, the shape_length and shape_area are then preserved within the output results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If anyone can give me advice in how to resolve the following, it would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;'''
Created on May 28, 2015
@author: PeterW
The following script calculates the volume for each Full Supply Level
to calculate the capacity curve for a proposed dam site
'''
# import system modules and site packages
import arcpy
# Check out 3D Analyst
arcpy.CheckOutExtension("3D")
# set environment settings
arcpy.env.overwriteOutput = True
# set input and output arguments
cont_line = r"F:\Projects\2015\PRCPTWAT02\13176\A34631\wspace\ChrisFox.gdb\Contours"
dw_line = r"F:\Projects\2015\PRCPTWAT02\13176\A34631\wspace\ChrisFox.gdb\Dam_Wall"
fsl_gon = r"F:\Projects\2015\PRCPTWAT02\13176\A34631\wspace\ChrisFox.gdb\Full_Supply_Level"
surf = r"F:\Projects\2015\PRCPTWAT02\13176\A34631\wspace\TIN\tin"
# make feature layer from the dam wall (polyline)
dwLyr = arcpy.MakeFeatureLayer_management(dw_line,"dwLayer")
# convert each FSL contour polyline into a FSL polygon and determine the volume
# below the contour elevation using the polygon volume tool
with arcpy.da.SearchCursor(cont_line,["Elevation"]) as cursor: &lt;A href="mailto:#@UndefinedVariable" rel="nofollow noopener noreferrer" target="_blank"&gt;#@UndefinedVariable&lt;/A&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in cursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elev = str(row[0])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outName = "FSL" + elev + "m"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sqlExp = "Elevation" + " = " + elev
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; contLyr = arcpy.MakeFeatureLayer_management(cont_line, outName, sqlExp)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fslLyr = "in_memory" + "\\" + outName
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.FeatureToPolygon_management([contLyr,dwLyr], fslLyr, attributes = True)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddField_management(fslLyr, "Elevation", "SHORT")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(fslLyr, "Elevation", elev, "PYTHON_9.3")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fields = arcpy.ListFields(fslLyr)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fields = [field.name for field in fields]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print fields
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.SearchCursor(fslLyr, fields) as sCur: &lt;A href="mailto:#@UndefinedVariable" rel="nofollow noopener noreferrer" target="_blank"&gt;#@UndefinedVariable&lt;/A&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.InsertCursor(fsl_gon, fields) as iCur: &lt;A href="mailto:#@UndefinedVariable" rel="nofollow noopener noreferrer" target="_blank"&gt;#@UndefinedVariable&lt;/A&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for sRow in sCur:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; iCur.insertRow(sRow)

# calculate the volume and surface area for each Full Supply Level polygon and the TIN 
arcpy.PolygonVolume_3d(surf, fsl_gon, "Elevation", "BELOW", "SVolume", "SArea","0")

# print statement that process is completed
arcpy.AddMessage("Completed Processing Capacity Curves")&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Peter Wilson&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:44:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-feature-to-polygon-in-memory/m-p/412894#M32494</guid>
      <dc:creator>PeterWilson</dc:creator>
      <dc:date>2021-12-11T18:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy: Feature to Polygon (in_memory)</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-feature-to-polygon-in-memory/m-p/412895#M32495</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use &lt;A href="http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/add-geometry-attributes.htm"&gt;Add Geometry Attribute &lt;/A&gt;to add the geometry attributes you want (more than just area and perimeter) to the in-memory feature classes.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 May 2015 02:33:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-feature-to-polygon-in-memory/m-p/412895#M32495</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-05-29T02:33:29Z</dc:date>
    </item>
  </channel>
</rss>

