<?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: Why would a Python script output an empty feature class for on xy to point process, but not another? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/why-would-a-python-script-output-an-empty-feature/m-p/335517#M26258</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Leah, you might want to format so people have line numbers for referencing your code&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting"&gt;/blogs/dan_patterson/2016/08/14/script-formatting&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 28 Mar 2019 02:28:41 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2019-03-28T02:28:41Z</dc:date>
    <item>
      <title>Why would a Python script output an empty feature class for on xy to point process, but not another?</title>
      <link>https://community.esri.com/t5/python-questions/why-would-a-python-script-output-an-empty-feature/m-p/335512#M26253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a Python script using Python 2.7 and arcpy (not from Pro).&amp;nbsp; This script queries a sql server database and writes the results to a table.&amp;nbsp; I then try to use that tables xy columns to create points with the XY event layer tool and copy features in the script.&amp;nbsp; All seems to go okay until I get an empty output.&amp;nbsp; I have run this in desktop, and it works from the same table that is created, I have tried it in Pro with the XYTableToPoints tool and it works.&amp;nbsp; I have tried creating a model and using that, it works when the model runs in the application, but not in the script.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have another similar script that works fine...but for some reason this one is not happy..even though I copied most of the code just modifying the query and the output fields.&amp;nbsp; Any ideas or has anyone seen this?&amp;nbsp; The version I'm running on this server is 10.5.1 as there are other dependencies for some automated scripts that run on the same server.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Mar 2019 01:30:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-would-a-python-script-output-an-empty-feature/m-p/335512#M26253</guid>
      <dc:creator>LSaunders</dc:creator>
      <dc:date>2019-03-27T01:30:38Z</dc:date>
    </item>
    <item>
      <title>Re: Why would a Python script output an empty feature class for on xy to point process, but not another?</title>
      <link>https://community.esri.com/t5/python-questions/why-would-a-python-script-output-an-empty-feature/m-p/335513#M26254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is hard to tell the differences in your scenarios, perhaps the code snippets would help&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Mar 2019 01:34:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-would-a-python-script-output-an-empty-feature/m-p/335513#M26254</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-03-27T01:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: Why would a Python script output an empty feature class for on xy to point process, but not another?</title>
      <link>https://community.esri.com/t5/python-questions/why-would-a-python-script-output-an-empty-feature/m-p/335514#M26255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The funny (or not so funny thing) is that the code is pretty much the same.&amp;nbsp; the scripts are over 200 lines long.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the gut of the arcpy code that works to create the table, but makes an empty point layer (excuse the mess as I have been attempting everything, usually I am much more clean with my tools):&lt;/P&gt;&lt;P&gt;arcpy.CreateTable_management(arcpy.env.workspace,'THEFTS_TABLE',arcpy.env.scratchWorkspace + '\\TABLE_TEMPLATE')&lt;BR /&gt; count = 0&lt;BR /&gt; with arcpy.da.InsertCursor(arcpy.env.workspace + '\\THEFTS_TABLE',fields) as insertcur:&lt;BR /&gt; for row in result:&lt;BR /&gt; report_id = row[0]&lt;BR /&gt; reporting_event_number = row[1]&lt;BR /&gt; veh_descr = row[2]&lt;BR /&gt; vehicle_make = row[3]&lt;BR /&gt; vehicle_model = row[4]&lt;BR /&gt; license_plate = row[5]&lt;BR /&gt; year_of_manufacture = row[6]&lt;BR /&gt; vin = row[7]&lt;BR /&gt; primary_color = row[8]&lt;BR /&gt; secondary_color = row[9]&lt;BR /&gt; item_status = row[10]&lt;BR /&gt; offense_code_statute = row[11]&lt;BR /&gt; nibrs_code = row[12]&lt;BR /&gt; nibrs_description = row[13]&lt;BR /&gt; stolen_date = row[14]&lt;BR /&gt; stolen_address = row[15]&lt;BR /&gt; stolen_beat = row[16]&lt;BR /&gt; stolen_long_to_map = row[17]&lt;BR /&gt; stolen_lat_to_map = row[18]&lt;BR /&gt; location_link_type = row[19]&lt;BR /&gt; recovered_date = row[20]&lt;BR /&gt; recovered_address = row[21]&lt;BR /&gt; recovered_precinct = row[22]&lt;BR /&gt; recovered_beat = row[23]&lt;BR /&gt; recovered_lat = row[24]&lt;BR /&gt; recovered_long = row[25]&lt;BR /&gt; recovered_by = row[26]&lt;BR /&gt; recovered_by_other_name = row[27]&lt;/P&gt;&lt;P&gt;insertcur.insertRow((report_id,reporting_event_number,veh_descr,vehicle_make,vehicle_model,license_plate,year_of_manufacture,vin,primary_color,secondary_color,item_status,offense_code_statute,nibrs_code,nibrs_description,&lt;BR /&gt; stolen_date,stolen_address,stolen_beat,stolen_long_to_map,stolen_lat_to_map,location_link_type,recovered_date,recovered_address,recovered_precinct,recovered_beat,recovered_lat,recovered_long,recovered_by,recovered_by_other_name))&lt;BR /&gt; print ("Row inserted")&lt;BR /&gt; count = count +1&lt;BR /&gt; logger.info("Thefts table finished loading. " + str(count) + " rows loaded.")&lt;BR /&gt; print (count)&lt;/P&gt;&lt;P&gt;#create data&lt;BR /&gt; print ('Running tools')&lt;BR /&gt; logger.info ('Creating feature class')&lt;BR /&gt; layer = 'xylayer'&lt;BR /&gt; spRef = arcpy.SpatialReference("WGS 1984")&lt;BR /&gt;#arcpy.CreateMVTFeatures_MVT() Trying to use a model - doesn't work&lt;/P&gt;&lt;P&gt;arcpy.MakeXYEventLayer_management(r'E:\Mark43_MVTUpdate\Thefts.gdb\THEFTS_TABLE',"stolen_long_to_map","stolen_lat_to_map",layer,4326)&lt;BR /&gt;arcpy.CopyFeatures_management(layer,'outputfeatures')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the one that works (it does call a tool in a toolbox, but I tried that even with the above one and no luck:&lt;/P&gt;&lt;P&gt;arcpy.CreateTable_management(arcpy.env.scratchWorkspace,'INCIDENTS_TABLE',arcpy.env.scratchWorkspace + '\\TABLE_TEMPLATE')&lt;BR /&gt; count = 0&lt;BR /&gt; with arcpy.da.InsertCursor(arcpy.env.scratchWorkspace + '\\INCIDENTS_TABLE',fields) as insertcur:&lt;BR /&gt; for row in result:&lt;BR /&gt; report_id = row[0]&lt;BR /&gt; report_type = row[1]&lt;BR /&gt; reporting_event_number = row[2]&lt;BR /&gt; approval_status = row[3]&lt;BR /&gt; offense_start_datetime = row[4]&lt;BR /&gt; offense_end_datetime = row[5]&lt;BR /&gt; offense_order = row[6]&lt;BR /&gt; offense_code_statute = row[7]&lt;BR /&gt; offense_description = row[8]&lt;BR /&gt; nibrs_code = row[9]&lt;BR /&gt; nibrs_description = row[10]&lt;BR /&gt; offense_type = row[11]&lt;BR /&gt; long_to_map = row[12]&lt;BR /&gt; lat_to_map = row[13]&lt;BR /&gt; coords_used = row[14]&lt;BR /&gt; address_to_map = row[15]&lt;BR /&gt; apartment_to_map = row[16]&lt;BR /&gt; precinct_to_map = row[17]&lt;BR /&gt; beat_to_map = row[18]&lt;/P&gt;&lt;P&gt;insertcur.insertRow((report_id,report_type,reporting_event_number,approval_status,offense_start_datetime,offense_end_datetime,offense_order,offense_code_statute,offense_description,nibrs_code,nibrs_description,&lt;BR /&gt; offense_type,long_to_map,lat_to_map,coords_used,address_to_map,apartment_to_map,precinct_to_map,beat_to_map))&lt;BR /&gt; print "Row inserted"&lt;BR /&gt; count = count +1&lt;BR /&gt; logger.info("Incidents table finished loading. " + str(count) + " rows loaded.")&lt;BR /&gt; print count&lt;/P&gt;&lt;P&gt;#create data&lt;BR /&gt; print ('Running tools')&lt;BR /&gt; logger.info ('Creating feature class')&lt;BR /&gt; arcpy.CreateFeatureClass_DataUpdate(arcpy.env.scratchWorkspace + '\\INCIDENTS_TABLE', 'long_to_map','lat_to_map',arcpy.env.workspace + '\\Incidents_Citywide')&lt;BR /&gt; logger.info('Tools have finished!')&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Mar 2019 01:48:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-would-a-python-script-output-an-empty-feature/m-p/335514#M26255</guid>
      <dc:creator>LSaunders</dc:creator>
      <dc:date>2019-03-27T01:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: Why would a Python script output an empty feature class for on xy to point process, but not another?</title>
      <link>https://community.esri.com/t5/python-questions/why-would-a-python-script-output-an-empty-feature/m-p/335515#M26256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you run your script from within the interactive Python window in ArcMap/ArcCatalog, does it work?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Mar 2019 15:56:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-would-a-python-script-output-an-empty-feature/m-p/335515#M26256</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2019-03-27T15:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: Why would a Python script output an empty feature class for on xy to point process, but not another?</title>
      <link>https://community.esri.com/t5/python-questions/why-would-a-python-script-output-an-empty-feature/m-p/335516#M26257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I hadn't tried..until now!&amp;nbsp; So it gives me an empty output..but when I run the actual model that gets called on the same data, it creates a point output as expected....not sure what this means!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2019 02:06:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-would-a-python-script-output-an-empty-feature/m-p/335516#M26257</guid>
      <dc:creator>LSaunders</dc:creator>
      <dc:date>2019-03-28T02:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: Why would a Python script output an empty feature class for on xy to point process, but not another?</title>
      <link>https://community.esri.com/t5/python-questions/why-would-a-python-script-output-an-empty-feature/m-p/335517#M26258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Leah, you might want to format so people have line numbers for referencing your code&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting"&gt;/blogs/dan_patterson/2016/08/14/script-formatting&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2019 02:28:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-would-a-python-script-output-an-empty-feature/m-p/335517#M26258</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-03-28T02:28:41Z</dc:date>
    </item>
    <item>
      <title>Re: Why would a Python script output an empty feature class for on xy to point process, but not another?</title>
      <link>https://community.esri.com/t5/python-questions/why-would-a-python-script-output-an-empty-feature/m-p/335518#M26259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My IDE does, but they don't get copied.&amp;nbsp; This is a very large script, and I just grabbed a smaller portion of it where arcpy is being used.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm thinking about just writing the insert cursor to create the geometry and push it into a feature class, as I can't figure out why only this one script (out of almost 10 that do the same thing) isn't working.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2019 02:33:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-would-a-python-script-output-an-empty-feature/m-p/335518#M26259</guid>
      <dc:creator>LSaunders</dc:creator>
      <dc:date>2019-03-28T02:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: Why would a Python script output an empty feature class for on xy to point process, but not another?</title>
      <link>https://community.esri.com/t5/python-questions/why-would-a-python-script-output-an-empty-feature/m-p/335519#M26260</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The syntax for copy and pasting code blocks so they are retains is explained in the link, otherwise it comes out with indentation lost and no line numbering&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Mar 2019 02:50:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/why-would-a-python-script-output-an-empty-feature/m-p/335519#M26260</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2019-03-28T02:50:15Z</dc:date>
    </item>
  </channel>
</rss>

