<?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 losing information when creating a shapefile in ArcGIS Network Analyst Questions</title>
    <link>https://community.esri.com/t5/arcgis-network-analyst-questions/losing-information-when-creating-a-shapefile/m-p/474228#M4613</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I m using ArcGIS 10.4.1 and NetworkAnalyst. The following code is used to read a table in a database and create a points shapefile:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;BR /&gt;import csv&lt;BR /&gt;import pyodbc&lt;BR /&gt;TABLE_NAME = "ad0127_2403$";&lt;BR /&gt;try:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;cn = pyodbc.connect('DRIVER={SQL Server};SERVER=*******;DATABASE=routing;trusted_connection=yes')&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;sql = "select Row_ID, Sys_Date, Latitude, Longitude, Dop, Speed, Mobile_ID_1, is_pod from dbo."+TABLE_NAME+" where is_pod = 224 order by Sys_Date"&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;cur = cn.cursor()&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;cur.execute(sql)&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;the_data = cur.fetchall()&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;cn.commit()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;OPoint = arcpy.Point() &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;pointGeometryList = []&lt;BR /&gt; &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;for row in the_data:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;OPoint.Y = float(row[2]) &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;OPoint.X = float(row[3])&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Speed = float(row[4])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;spRef = arcpy.SpatialReference("WGS 1984") &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;pointGeometry = arcpy.PointGeometry(OPoint,spRef)&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;pointGeometryList.append(pointGeometry)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;# Output the result &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;# Copy features to shapefile&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.CopyFeatures_management(pointGeometryList, &amp;nbsp;&amp;nbsp;&amp;nbsp;r"C:\Users\*****\Desktop\ROUTES\testingRoutess\testing.shp")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.AddXY_management(r"C:\Users\******\Desktop\ROUTES\testingRoutess\testing.shp")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;except Exception as e:&lt;BR /&gt; # If an error occurred, print line number and error message&lt;BR /&gt; import traceback, sys&lt;BR /&gt; tb = sys.exc_info()[2]&lt;BR /&gt; print "An error occured on line %i" % tb.tb_lineno&lt;BR /&gt; print str(e)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem that i m facing has to do with the fact that the created shapefile's attribute table is missing crucial information.The source table has the following fields&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image j-img-original" src="/legacyfs/online/392983_original table.PNG" style="width: 620px; height: 222px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the shapefile's attribute table has the following fields&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-2 jive-image j-img-original" src="/legacyfs/online/392987_attribute table.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any way or python method to auto add more fields (i.e Speed) in the attribute table? Any help would be appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Jan 2018 18:21:52 GMT</pubDate>
    <dc:creator>sotokan80_</dc:creator>
    <dc:date>2018-01-16T18:21:52Z</dc:date>
    <item>
      <title>losing information when creating a shapefile</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/losing-information-when-creating-a-shapefile/m-p/474228#M4613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I m using ArcGIS 10.4.1 and NetworkAnalyst. The following code is used to read a table in a database and create a points shapefile:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;BR /&gt;import csv&lt;BR /&gt;import pyodbc&lt;BR /&gt;TABLE_NAME = "ad0127_2403$";&lt;BR /&gt;try:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;cn = pyodbc.connect('DRIVER={SQL Server};SERVER=*******;DATABASE=routing;trusted_connection=yes')&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;sql = "select Row_ID, Sys_Date, Latitude, Longitude, Dop, Speed, Mobile_ID_1, is_pod from dbo."+TABLE_NAME+" where is_pod = 224 order by Sys_Date"&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;cur = cn.cursor()&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;cur.execute(sql)&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;the_data = cur.fetchall()&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;cn.commit()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;OPoint = arcpy.Point() &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;pointGeometryList = []&lt;BR /&gt; &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;for row in the_data:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;OPoint.Y = float(row[2]) &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;OPoint.X = float(row[3])&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Speed = float(row[4])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;spRef = arcpy.SpatialReference("WGS 1984") &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;pointGeometry = arcpy.PointGeometry(OPoint,spRef)&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;pointGeometryList.append(pointGeometry)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;# Output the result &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;# Copy features to shapefile&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.CopyFeatures_management(pointGeometryList, &amp;nbsp;&amp;nbsp;&amp;nbsp;r"C:\Users\*****\Desktop\ROUTES\testingRoutess\testing.shp")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.AddXY_management(r"C:\Users\******\Desktop\ROUTES\testingRoutess\testing.shp")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;except Exception as e:&lt;BR /&gt; # If an error occurred, print line number and error message&lt;BR /&gt; import traceback, sys&lt;BR /&gt; tb = sys.exc_info()[2]&lt;BR /&gt; print "An error occured on line %i" % tb.tb_lineno&lt;BR /&gt; print str(e)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem that i m facing has to do with the fact that the created shapefile's attribute table is missing crucial information.The source table has the following fields&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-1 jive-image j-img-original" src="/legacyfs/online/392983_original table.PNG" style="width: 620px; height: 222px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the shapefile's attribute table has the following fields&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-2 jive-image j-img-original" src="/legacyfs/online/392987_attribute table.PNG" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there any way or python method to auto add more fields (i.e Speed) in the attribute table? Any help would be appreciated.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jan 2018 18:21:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/losing-information-when-creating-a-shapefile/m-p/474228#M4613</guid>
      <dc:creator>sotokan80_</dc:creator>
      <dc:date>2018-01-16T18:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: losing information when creating a shapefile</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/losing-information-when-creating-a-shapefile/m-p/474229#M4614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you only create the x, y coordinates for the output.&amp;nbsp; do you have a common field that you can use in a join?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jan 2018 19:12:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/losing-information-when-creating-a-shapefile/m-p/474229#M4614</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-01-16T19:12:42Z</dc:date>
    </item>
    <item>
      <title>Re: losing information when creating a shapefile</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/losing-information-when-creating-a-shapefile/m-p/474230#M4615</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The common fields are those with the coordinates. But I was trying to avoid joining the tables because i get too many unused fields or empty fields. Is there any other way to add fields in the attribute table?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jan 2018 19:36:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/losing-information-when-creating-a-shapefile/m-p/474230#M4615</guid>
      <dc:creator>sotokan80_</dc:creator>
      <dc:date>2018-01-16T19:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: losing information when creating a shapefile</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/losing-information-when-creating-a-shapefile/m-p/474231#M4616</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use an &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-data-access/insertcursor-class.htm"&gt;&lt;STRONG&gt;insertcursor&lt;/STRONG&gt;&lt;/A&gt; and do it that way, or you could simply add &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/delete-field.htm"&gt;&lt;STRONG&gt;Delete Field &lt;/STRONG&gt;&lt;/A&gt;in a loop.&amp;nbsp; This option is much simpler particularly if your field names remain the same between runs, as they might)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jan 2018 19:45:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/losing-information-when-creating-a-shapefile/m-p/474231#M4616</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-01-16T19:45:24Z</dc:date>
    </item>
    <item>
      <title>Re: losing information when creating a shapefile</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/losing-information-when-creating-a-shapefile/m-p/474232#M4617</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can simplify this by running the &lt;A href="http://desktop.arcgis.com/en/arcmap/10.5/tools/data-management-toolbox/make-xy-event-layer.htm"&gt;Make XY Event Layer &lt;/A&gt;function in your script.&amp;nbsp; This will retain all of your attributes.&amp;nbsp; You can then use the CopyFeatures function to copy this to a shapefile.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jan 2018 20:09:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/losing-information-when-creating-a-shapefile/m-p/474232#M4617</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2018-01-16T20:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: losing information when creating a shapefile</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/losing-information-when-creating-a-shapefile/m-p/474233#M4618</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you give me a small tip on how to use&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;the&lt;/SPAN&gt;&amp;nbsp;make X Y event function.Do i have to create a temporary table because the function's syntax specifies that there is an input table&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jan 2018 20:17:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/losing-information-when-creating-a-shapefile/m-p/474233#M4618</guid>
      <dc:creator>sotokan80_</dc:creator>
      <dc:date>2018-01-16T20:17:38Z</dc:date>
    </item>
    <item>
      <title>Re: losing information when creating a shapefile</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/losing-information-when-creating-a-shapefile/m-p/474234#M4619</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You would reference your database table through a &lt;A href="http://desktop.arcgis.com/en/arcmap/10.5/manage-data/databases/database-connections-desktop.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Database Connection&lt;/A&gt;.&amp;nbsp; In the below example I'm connecting to a SQL Server database (not a geodatabase) and referencing a table called XY, creating the event layer, then exporting to a shapefile:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
&lt;SPAN class="keyword token"&gt;from&lt;/SPAN&gt; arcpy &lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; env
env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;workspace &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"Database Connections\SQLSERVER - DBO@NONGDB.sde"&lt;/SPAN&gt;

table &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"XY"&lt;/SPAN&gt;

sr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SpatialReference&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;4326&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MakeXYEventLayer_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;table&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"x"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"y"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"XY_Layer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; sr&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CopyFeatures_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"XY_Layer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"D:\temp\python\XY_Points.shp"&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:57:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/losing-information-when-creating-a-shapefile/m-p/474234#M4619</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T20:57:50Z</dc:date>
    </item>
    <item>
      <title>Re: losing information when creating a shapefile</title>
      <link>https://community.esri.com/t5/arcgis-network-analyst-questions/losing-information-when-creating-a-shapefile/m-p/474235#M4620</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Jake... cool new tool in Pro... simplifies the process &lt;A href="http://pro.arcgis.com/en/pro-app/tool-reference/data-management/xy-table-to-point.htm"&gt;&lt;STRONG&gt;XY Table to Point&lt;/STRONG&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jan 2018 21:20:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-network-analyst-questions/losing-information-when-creating-a-shapefile/m-p/474235#M4620</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-01-16T21:20:34Z</dc:date>
    </item>
  </channel>
</rss>

