<?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: createFeatureClass from txt file of coordinates in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/createfeatureclass-from-txt-file-of-coordinates/m-p/1116456#M47789</link>
    <description>&lt;P&gt;I've never used the split() function as shown above.&amp;nbsp; Typically the split function is used with just a delimiter like&amp;nbsp; this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;x = '123,456'
newX = x.split(',')
# which returns a list of ['123', 456']&lt;/LI-CODE&gt;&lt;P&gt;All that said, I would simplify things and start with replacing the spaces in your text file with a comma, and call the new file coords.csv.&amp;nbsp; You'll need to add a line on the top naming the fields.&amp;nbsp; &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/xy-table-to-point.htm" target="_self"&gt;Then use XY table to Point&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Nov 2021 18:48:55 GMT</pubDate>
    <dc:creator>JoeBorgione</dc:creator>
    <dc:date>2021-11-12T18:48:55Z</dc:date>
    <item>
      <title>createFeatureClass from txt file of coordinates</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/createfeatureclass-from-txt-file-of-coordinates/m-p/1116426#M47785</link>
      <description>&lt;P&gt;Hi. I'm trying to learn how to read a txt file of coordinates into an arcpy script, and create a featureclass from those coordinates.&amp;nbsp; The only examples I find in the community posts address/solve different aspects than where my script fails.&amp;nbsp; I have copied the key steps directly from the Zandbergen (2013) text, which includes an exercise/code to convert a txt file into a polyline (I had hoped to creat a point file first, then a polyline, and then modify to create polygons from a different txt file.&lt;/P&gt;&lt;P&gt;My script is:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;arcpy&lt;BR /&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;fileinput&lt;BR /&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;string&lt;BR /&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;os&lt;BR /&gt;arcpy.env.workspace = &lt;SPAN&gt;r"E:\advAppScripting\testing\hawaii"&lt;BR /&gt;&lt;/SPAN&gt;arcpy.env.overwriteOutput = &lt;SPAN&gt;True&lt;BR /&gt;&lt;/SPAN&gt;out_path = &lt;SPAN&gt;r"E:\advAppScripting\testing\hawaii"&lt;BR /&gt;&lt;/SPAN&gt;new_fc = &lt;SPAN&gt;"myline.shp"&lt;BR /&gt;&lt;/SPAN&gt;fc_geom = &lt;SPAN&gt;"POLYLINE"&lt;BR /&gt;&lt;/SPAN&gt;newSR = &lt;SPAN&gt;26904&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;try&lt;/SPAN&gt;:&lt;BR /&gt;    arcpy.CreateFeatureclass_management(out_path&lt;SPAN&gt;, &lt;/SPAN&gt;new_fc&lt;SPAN&gt;, &lt;/SPAN&gt;fc_geom)&lt;BR /&gt;    &lt;SPAN&gt;# it should be possible to include the spatial reference as the final parameter in CreateFeatureclass, but it fails&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;    # unless I remove it, and do the searate DefineProjection below...???&lt;BR /&gt;&lt;/SPAN&gt;    arcpy.DefineProjection_management(new_fc&lt;SPAN&gt;, &lt;/SPAN&gt;newSR)&lt;BR /&gt;    &lt;SPAN&gt;#I've confirmed successful operation ofhte script though line 16..&lt;BR /&gt;&lt;/SPAN&gt;    infile = &lt;SPAN&gt;r"E:\advAppScripting\testing\hawaii\coordinates.txt"&lt;BR /&gt;&lt;/SPAN&gt;    cursor = arcpy.da.InsertCursor(new_fc&lt;SPAN&gt;, &lt;/SPAN&gt;[&lt;SPAN&gt;"SHAPE@"&lt;/SPAN&gt;])&lt;BR /&gt;    array = arcpy.Array()&lt;BR /&gt;    &lt;SPAN&gt;for &lt;/SPAN&gt;line &lt;SPAN&gt;in &lt;/SPAN&gt;fileinput.input(infile):&lt;BR /&gt;        ID&lt;SPAN&gt;, &lt;/SPAN&gt;X&lt;SPAN&gt;, &lt;/SPAN&gt;Y = string.split(line&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;" "&lt;/SPAN&gt;)&lt;BR /&gt;        &lt;SPAN&gt;# I think this is supposed to read each line of the infile and parse it as the column headings in the new_fc.&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;        #  generates a "module 'string' has no attribute 'split'" error message&lt;BR /&gt;&lt;/SPAN&gt;        cursor.insertRow([arcpy.Polyline(array)])&lt;BR /&gt;    &lt;SPAN&gt;# I thought this line should be part of the iteration through the rows, but in the example I've followed, its not indented&lt;BR /&gt;&lt;/SPAN&gt;    fileinput.close()&lt;BR /&gt;    &lt;SPAN&gt;del &lt;/SPAN&gt;cursor&lt;BR /&gt;&lt;SPAN&gt;except &lt;/SPAN&gt;&lt;SPAN&gt;Exception &lt;/SPAN&gt;&lt;SPAN&gt;as &lt;/SPAN&gt;e:&lt;BR /&gt;    &lt;SPAN&gt;print&lt;/SPAN&gt;(&lt;SPAN&gt;"Error: " &lt;/SPAN&gt;+ e.args[&lt;SPAN&gt;0&lt;/SPAN&gt;])&lt;BR /&gt;&lt;BR /&gt;I think the problem may be that the string.split() is 'old Python' and no longer works,&lt;BR /&gt;but I'm unsure how to resolve.&lt;BR /&gt;&lt;BR /&gt;Would appreciate any help/advice.  I am attaching the associated txt file&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Nov 2021 17:42:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/createfeatureclass-from-txt-file-of-coordinates/m-p/1116426#M47785</guid>
      <dc:creator>PhilCrossley1</dc:creator>
      <dc:date>2021-11-12T17:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: createFeatureClass from txt file of coordinates</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/createfeatureclass-from-txt-file-of-coordinates/m-p/1116456#M47789</link>
      <description>&lt;P&gt;I've never used the split() function as shown above.&amp;nbsp; Typically the split function is used with just a delimiter like&amp;nbsp; this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;x = '123,456'
newX = x.split(',')
# which returns a list of ['123', 456']&lt;/LI-CODE&gt;&lt;P&gt;All that said, I would simplify things and start with replacing the spaces in your text file with a comma, and call the new file coords.csv.&amp;nbsp; You'll need to add a line on the top naming the fields.&amp;nbsp; &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/xy-table-to-point.htm" target="_self"&gt;Then use XY table to Point&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Nov 2021 18:48:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/createfeatureclass-from-txt-file-of-coordinates/m-p/1116456#M47789</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-11-12T18:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: createFeatureClass from txt file of coordinates</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/createfeatureclass-from-txt-file-of-coordinates/m-p/1116630#M47809</link>
      <description>&lt;P&gt;Thanks! This does seem like a much simpler approach.&amp;nbsp; I've been trying to implement it for 3 hours now....with repeated failures for 'invalid geometry'--even though if I run the XYTabletoPoint tool within Pro (2.8) it works; it just fails if I try to call that tool within arcpy. I'm pasting my new script, and also the new (stripped down) version of the table, in case you are willing to provide further assistance in spite of your desire to retire....&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;arcpy&lt;BR /&gt;&lt;SPAN&gt;from &lt;/SPAN&gt;arcpy &lt;SPAN&gt;import &lt;/SPAN&gt;env&lt;BR /&gt;env.workspace = &lt;SPAN&gt;r"E:\advAppScripting\testing\hawaii"&lt;BR /&gt;&lt;/SPAN&gt;env.overwriteOutput = &lt;SPAN&gt;True&lt;BR /&gt;&lt;/SPAN&gt;infile = &lt;SPAN&gt;r"E:\advAppScripting\testing\hawaii\testpoints3.csv"&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;try&lt;/SPAN&gt;:&lt;BR /&gt;    arcpy.CreateFileGDB_management(&lt;SPAN&gt;r"E:\advAppScripting\testing\hawaii"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"testing"&lt;/SPAN&gt;)&lt;BR /&gt;    &lt;SPAN&gt;# had originaly tried to just create a .shp file, but after it failed, changed to creating a featureclass&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;    # hence the need to create a new gdb first&lt;BR /&gt;&lt;/SPAN&gt;    arcpy.XYTableToPoint_management(infile&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;r"E:\advAppScripting\testing\hawaii\testing.gdb\myNEWpoints"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;                                    &lt;SPAN&gt;"EASTING"&lt;/SPAN&gt;&lt;SPAN&gt;,   &lt;/SPAN&gt;&lt;SPAN&gt;"NORTHING"&lt;/SPAN&gt;)&lt;BR /&gt;    &lt;SPAN&gt;# the tool help claims you can specify the spatial ref. as a tool parameter, but when I do, script fails with&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;    # 'not a field' error meesage, so switched to definine projection as a separate step&lt;BR /&gt;&lt;/SPAN&gt;    arcpy.DefineProjection_management(&lt;SPAN&gt;r"E:\advAppScripting\testing\hawaii\testing.gdb\myNEWpoints"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;                                      arcpy.SpatialReference(&lt;SPAN&gt;26904&lt;/SPAN&gt;))&lt;BR /&gt;    &lt;SPAN&gt;# this script creates a new gdb and a new feature class with the correct spatail ref. BUT no points are included&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;    # and a 'invalid geometry error is generated&lt;/SPAN&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 Nov 2021 19:08:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/createfeatureclass-from-txt-file-of-coordinates/m-p/1116630#M47809</guid>
      <dc:creator>PhilCrossley1</dc:creator>
      <dc:date>2021-11-13T19:08:36Z</dc:date>
    </item>
    <item>
      <title>Re: createFeatureClass from txt file of coordinates</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/createfeatureclass-from-txt-file-of-coordinates/m-p/1116973#M47850</link>
      <description>&lt;P&gt;Just in case anyone else is finding this same problem:&amp;nbsp; &amp;nbsp;Have been able to get the XYTabletoPoint to work by including None for the Vertical CS, instead of leaving that parameter blank, and without doing anything special to call the horizontal spatial ref., as shown below.&lt;/P&gt;&lt;PRE&gt;arcpy.XYTableToPoint_management(infile&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;r"E:\advAppScripting\testing\hawaii\testing.gdb\myNEWpoints"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;BR /&gt;&lt;/SPAN&gt;                                    &lt;SPAN&gt;"EASTING"&lt;/SPAN&gt;&lt;SPAN&gt;,   &lt;/SPAN&gt;&lt;SPAN&gt;"NORTHING", None, 26904&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Nov 2021 18:15:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/createfeatureclass-from-txt-file-of-coordinates/m-p/1116973#M47850</guid>
      <dc:creator>PhilCrossley1</dc:creator>
      <dc:date>2021-11-15T18:15:57Z</dc:date>
    </item>
  </channel>
</rss>

