<?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: Intersect Intermittently Produces Empty Output (run in Python script) in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/intersect-intermittently-produces-empty-output-run/m-p/219447#M7570</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good Question, but no, in every test done, the line has been drawn within at least one of the polygons. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 09 Apr 2020 20:01:13 GMT</pubDate>
    <dc:creator>DarrenConly</dc:creator>
    <dc:date>2020-04-09T20:01:13Z</dc:date>
    <item>
      <title>Intersect Intermittently Produces Empty Output (run in Python script)</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/intersect-intermittently-produces-empty-output-run/m-p/219445#M7568</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a function (copied/pasted below) that does the following:&lt;/P&gt;&lt;OL style="margin-top: 0in;"&gt;&lt;LI style="margin-left: 0in;"&gt;Inputs are a user-drawn line and a polygon layer of community types. The goal is to determine which polygon has the most overlap with the line. E.g., if a 1mi line has 0.3mi in community type A, 0.5mi in community type B, and 0.2mi in community type C, the function would return “community type B” as the value because B has the longest overlap distance with the line.&lt;/LI&gt;&lt;LI style="margin-left: 0in;"&gt;To do this, the function does an Intersect (highlighted in the code snippet) between the line and the polygons, returning a temporary line feature class in which each feature is the piece of the line in each community type. If the line was only in one community type, this temporary feature class would only have 1 feature.&lt;/LI&gt;&lt;LI style="margin-left: 0in;"&gt;Run a search cursor on the temp feature class, returning a dictionary whose items are {community type1: overlap distance for community type 1, community type 2: overlap distance for community type2, etc.}&lt;/LI&gt;&lt;LI style="margin-left: 0in;"&gt;Return the dictionary key (i.e., community type) whose value is the largest among the dict values, i.e., return the name of the community type as a string value for the community type polygon that has the most overlap with the line.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on some testing, the Intersect_analysis step intermittently (every 10-20 times the tool is run) returns an empty temporary feature class (doing a GetCount of it returns 0 features). If the temp feature class is empty, then there is no “max” overlap value, so in turn function returns an error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;get_proj_ctype&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;in_project_fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; commtypes_fc&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="string token"&gt;'''Get project community type, based on which community type has most spatial overlap with project'''&lt;/SPAN&gt;
    temp_intersect_fc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;join&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;scratchGDB&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'temp_intersect_fc'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# don't use "memory", use scratch GDB&lt;/SPAN&gt;
    arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Intersect_analysis&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;in_project_fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; commtypes_fc&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; temp_intersect_fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"ALL"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; 
                             &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"LINE"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    
    item_cnt &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetCount_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;temp_intersect_fc&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
    arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddMessage&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Project segments after intersecting with comm types: {}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;item_cnt&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    len_field &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'SHAPE@LENGTH'&lt;/SPAN&gt;
    fields &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'OBJECTID'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; len_field&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; params&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;col_ctype&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
    ctype_dist_dict &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
    
    &lt;SPAN class="keyword token"&gt;with&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;da&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SearchCursor&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;temp_intersect_fc&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; fields&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;as&lt;/SPAN&gt; cur&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; row &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; cur&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
            ctype &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;fields&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;index&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;params&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;col_ctype&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
            seg_len &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; row&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;fields&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;index&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;len_field&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
            
            &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; ctype_dist_dict&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;get&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;ctype&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;is&lt;/SPAN&gt; None&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
                ctype_dist_dict&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;ctype&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; seg_len
            &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
                ctype_dist_dict&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;ctype&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+=&lt;/SPAN&gt; seg_len
    &lt;SPAN class="keyword token"&gt;try&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        maxval &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; max&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;v &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; k&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; v &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; ctype_dist_dict&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;items&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
        proj_ctype &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;k &lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; k&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; v &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; ctype_dist_dict&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;items&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; v &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; maxval&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
 
        &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; proj_ctype
    &lt;SPAN class="keyword token"&gt;except&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;raise&lt;/SPAN&gt; ValueError&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"ERROR: No Community Type identified for project."&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;Any thoughts as to what's going on?&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;/P&gt;&lt;P style="background: white;"&gt;&lt;SPAN style="color: black; font-size: 10.0pt;"&gt;&lt;STRONG&gt;Further information:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI style="background: white;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;This is on a web tool hosted on ArcServer 10.7.1 and published by me via ArcGIS Pro interface&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI style="background: white;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;The community type polygon feature class is stored in an enterprise geodatabase&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI style="background: white;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;The line feature, as mentioned above, is drawn by the tool user as a tool input in a web browser interface.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI style="background: white;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;To repeat, this issue only arises every 10-20 (i.e., 90-95% of the time no problems) runs and I can find no pattern in terms of what causes it to arise.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI style="background: white;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;Tried already&lt;/SPAN&gt;&lt;UL&gt;&lt;LI style="background: white;"&gt;&lt;SPAN style="font-size: 10.0pt; color: black;"&gt;Searching for other GeoNet posts on this issue, most are for problems that are either in the desktop interface (not in python script, or they are for a very consistent problem. But none for an intermittent problem like mine.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:42:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/intersect-intermittently-produces-empty-output-run/m-p/219445#M7568</guid>
      <dc:creator>DarrenConly</dc:creator>
      <dc:date>2021-12-11T10:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: Intersect Intermittently Produces Empty Output (run in Python script)</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/intersect-intermittently-produces-empty-output-run/m-p/219446#M7569</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Got to ask the obvious question, when someone draws that line is it possible they have drawn a line that does not intersect any of your polygons? May be they are looking at the data at a zoomed out scale and what they think they are drawing on is actually missing the polygons?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 08 Apr 2020 10:22:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/intersect-intermittently-produces-empty-output-run/m-p/219446#M7569</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2020-04-08T10:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: Intersect Intermittently Produces Empty Output (run in Python script)</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/intersect-intermittently-produces-empty-output-run/m-p/219447#M7570</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good Question, but no, in every test done, the line has been drawn within at least one of the polygons. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Apr 2020 20:01:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/intersect-intermittently-produces-empty-output-run/m-p/219447#M7570</guid>
      <dc:creator>DarrenConly</dc:creator>
      <dc:date>2020-04-09T20:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: Intersect Intermittently Produces Empty Output (run in Python script)</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/intersect-intermittently-produces-empty-output-run/m-p/219448#M7571</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK one thing your function should be doing but it is not is to test if the input parameters actually have any data to intersect.&amp;nbsp;I assume&amp;nbsp;&lt;EM&gt;in_project_fc&lt;/EM&gt; is the line layer? I would check that actually has data in it. If you find it does not then this would indicate the issue is outside this function and at that point nobody can help you as we are not seeing the full code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On a side note you should always use the syntax highlighter when adding code as it makes it easier to read and in the case of python helps identify indentation issues. You can ALWAYS amend your original question...&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/488213_pastedImage_3.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Apr 2020 10:51:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/intersect-intermittently-produces-empty-output-run/m-p/219448#M7571</guid>
      <dc:creator>DuncanHornby</dc:creator>
      <dc:date>2020-04-10T10:51:04Z</dc:date>
    </item>
  </channel>
</rss>

