<?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 Splitting large amount of features in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/splitting-large-amount-of-features/m-p/18818#M1457</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We are publishing a geoprocessing service that will split a large amount of features in a file geodatabase.&amp;nbsp; The script uses the arcpy.defense.SplitFeatures() method, a&amp;nbsp;ResourceSrf layer or a user passed in&amp;nbsp;shapefile grid to split the features, so any features that fall within the grid or ResourceSrf should be split by the grid/ResourceSrf cell size.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue we are facing is that some features are split, while others are not, particularly polygon features.&amp;nbsp;&amp;nbsp;I am wondering if this is the best approach to splitting a large amount of features? Of course the documentation for this method is sparse at best.&amp;nbsp; Below is the code that splits the features.&amp;nbsp; Any help, information, or insight into splitting features would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;def &lt;/SPAN&gt;splitter(gdb_to_split, use_alt_surface):
    gdb_exchange_folder = os.path.join(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;r'F:\Exchange\Rework_Temp'&lt;/SPAN&gt;, gdb_to_split[:-&lt;SPAN style="color: #0000ff;"&gt;4&lt;/SPAN&gt;])
    gdb_to_split = os.path.join(gdb_exchange_folder, gdb_to_split)
    gdb_to_split_tds = os.path.join(gdb_to_split, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'TDS'&lt;/SPAN&gt;)

    &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;use_alt_surface:
        gdb_resource_srf = os.path.join(gdb_exchange_folder, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'clip_shape.shp'&lt;/SPAN&gt;)
    &lt;SPAN style="color: #000080; font-weight: bold;"&gt;else&lt;/SPAN&gt;:
        gdb_resource_srf = os.path.join(gdb_to_split, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'TDS'&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'ResourceSrf'&lt;/SPAN&gt;)

    &lt;SPAN style="color: #808080;"&gt;physio_srf &lt;/SPAN&gt;= os.path.join(gdb_to_split_tds, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'PhysiographySrf'&lt;/SPAN&gt;)

    target_features = &lt;SPAN style="color: #008000; font-weight: bold;"&gt;r''
&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-weight: bold;"&gt;    &lt;/SPAN&gt;arcpy.env.workspace = gdb_to_split_tds
    fcl = arcpy.ListFeatureClasses()
    &lt;SPAN style="color: #000080; font-weight: bold;"&gt;for &lt;/SPAN&gt;fclass &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;fcl:
        desc = arcpy.Describe(fclass)
        &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;desc.shapeType &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;'Polygon'&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'Polyline'&lt;/SPAN&gt;) &lt;SPAN style="color: #000080; font-weight: bold;"&gt;and &lt;/SPAN&gt;desc.name &lt;SPAN style="color: #000080; font-weight: bold;"&gt;not in &lt;/SPAN&gt;(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;'ResourceSrf'&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'MetadataSrf'&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'PhysiographySrf'&lt;/SPAN&gt;):
            target_features += os.path.join(gdb_to_split_tds, fclass) + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;';'
&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-weight: bold;"&gt;    &lt;/SPAN&gt;target_features = target_features[:-&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;]
    

    arcpy.management.MakeFeatureLayer(gdb_resource_srf, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"split_shape"&lt;/SPAN&gt;)
    arcpy.management.SelectLayerByLocation(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"split_shape"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"ARE_IDENTICAL_TO"&lt;/SPAN&gt;, gdb_resource_srf)

    arcpy.CheckOutExtension(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;'defense'&lt;/SPAN&gt;)&lt;SPAN style="color: #808080;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;    &lt;/SPAN&gt;arcpy.defense.SplitFeatures(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"split_shape"&lt;/SPAN&gt;, target_features)

    arcpy.Delete_management(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"split_shape"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 20:45:52 GMT</pubDate>
    <dc:creator>AdamG</dc:creator>
    <dc:date>2021-12-10T20:45:52Z</dc:date>
    <item>
      <title>Splitting large amount of features</title>
      <link>https://community.esri.com/t5/python-questions/splitting-large-amount-of-features/m-p/18818#M1457</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We are publishing a geoprocessing service that will split a large amount of features in a file geodatabase.&amp;nbsp; The script uses the arcpy.defense.SplitFeatures() method, a&amp;nbsp;ResourceSrf layer or a user passed in&amp;nbsp;shapefile grid to split the features, so any features that fall within the grid or ResourceSrf should be split by the grid/ResourceSrf cell size.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue we are facing is that some features are split, while others are not, particularly polygon features.&amp;nbsp;&amp;nbsp;I am wondering if this is the best approach to splitting a large amount of features? Of course the documentation for this method is sparse at best.&amp;nbsp; Below is the code that splits the features.&amp;nbsp; Any help, information, or insight into splitting features would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;def &lt;/SPAN&gt;splitter(gdb_to_split, use_alt_surface):
    gdb_exchange_folder = os.path.join(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;r'F:\Exchange\Rework_Temp'&lt;/SPAN&gt;, gdb_to_split[:-&lt;SPAN style="color: #0000ff;"&gt;4&lt;/SPAN&gt;])
    gdb_to_split = os.path.join(gdb_exchange_folder, gdb_to_split)
    gdb_to_split_tds = os.path.join(gdb_to_split, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'TDS'&lt;/SPAN&gt;)

    &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;use_alt_surface:
        gdb_resource_srf = os.path.join(gdb_exchange_folder, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'clip_shape.shp'&lt;/SPAN&gt;)
    &lt;SPAN style="color: #000080; font-weight: bold;"&gt;else&lt;/SPAN&gt;:
        gdb_resource_srf = os.path.join(gdb_to_split, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'TDS'&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'ResourceSrf'&lt;/SPAN&gt;)

    &lt;SPAN style="color: #808080;"&gt;physio_srf &lt;/SPAN&gt;= os.path.join(gdb_to_split_tds, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'PhysiographySrf'&lt;/SPAN&gt;)

    target_features = &lt;SPAN style="color: #008000; font-weight: bold;"&gt;r''
&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-weight: bold;"&gt;    &lt;/SPAN&gt;arcpy.env.workspace = gdb_to_split_tds
    fcl = arcpy.ListFeatureClasses()
    &lt;SPAN style="color: #000080; font-weight: bold;"&gt;for &lt;/SPAN&gt;fclass &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;fcl:
        desc = arcpy.Describe(fclass)
        &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;desc.shapeType &lt;SPAN style="color: #000080; font-weight: bold;"&gt;in &lt;/SPAN&gt;(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;'Polygon'&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'Polyline'&lt;/SPAN&gt;) &lt;SPAN style="color: #000080; font-weight: bold;"&gt;and &lt;/SPAN&gt;desc.name &lt;SPAN style="color: #000080; font-weight: bold;"&gt;not in &lt;/SPAN&gt;(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;'ResourceSrf'&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'MetadataSrf'&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'PhysiographySrf'&lt;/SPAN&gt;):
            target_features += os.path.join(gdb_to_split_tds, fclass) + &lt;SPAN style="color: #008000; font-weight: bold;"&gt;';'
&lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-weight: bold;"&gt;    &lt;/SPAN&gt;target_features = target_features[:-&lt;SPAN style="color: #0000ff;"&gt;1&lt;/SPAN&gt;]
    

    arcpy.management.MakeFeatureLayer(gdb_resource_srf, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"split_shape"&lt;/SPAN&gt;)
    arcpy.management.SelectLayerByLocation(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"split_shape"&lt;/SPAN&gt;, &lt;SPAN style="color: #008000; font-weight: bold;"&gt;"ARE_IDENTICAL_TO"&lt;/SPAN&gt;, gdb_resource_srf)

    arcpy.CheckOutExtension(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;'defense'&lt;/SPAN&gt;)&lt;SPAN style="color: #808080;"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;    &lt;/SPAN&gt;arcpy.defense.SplitFeatures(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"split_shape"&lt;/SPAN&gt;, target_features)

    arcpy.Delete_management(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"split_shape"&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:45:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/splitting-large-amount-of-features/m-p/18818#M1457</guid>
      <dc:creator>AdamG</dc:creator>
      <dc:date>2021-12-10T20:45:52Z</dc:date>
    </item>
  </channel>
</rss>

