<?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: How can I create points from attributes? in Data Management Questions</title>
    <link>https://community.esri.com/t5/data-management-questions/how-can-i-create-points-from-attributes/m-p/589320#M33276</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I manually entered the coords in the attribute table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;How did you get your coordinates?&amp;nbsp; You could use arcpy &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018z0000006t000000" target="_blank" rel="nofollow noopener noreferrer"&gt;point geometry&lt;/A&gt; or an &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018w0000000t000000" target="_blank" rel="nofollow noopener noreferrer"&gt;insert cursor&lt;/A&gt; to build your point feature class.&amp;nbsp; Here is an example of how you can do this by reading x,y coords from a csv and making a point feature class.&lt;BR /&gt;&lt;BR /&gt;This is what the csv looks like:&lt;BR /&gt;&lt;BR /&gt;Line_ID,X_Coord,Y_Coord,Length,NAME1,JOIN_FID,Type&lt;BR /&gt;1,2317355.49962,681731.016618,1315.40287879,SPICER AVENUE,1,Start&lt;BR /&gt;2,2317485.73951,676450.010776,5316.04898921,SPICER AVENUE,2,Start&lt;BR /&gt;3,2317627.9246,671135.874095,5294.36015714,190TH STREET,3,Start&lt;BR /&gt;4,2317355.49962,681731.016618,5376.75305576,170TH STREET,4,Start&lt;BR /&gt;&lt;BR /&gt;I just split this list by commas to get the 2nd and third columns which are the x and y coordinates and created a tuple for the shape field.&amp;nbsp; Here is how it can be done in 10.1.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
arcpy.env.overwriteOutput = True


# Coords stored in a csv
csv = r'G:\PROJECTS\Cedar\GeneralScripts\PyLibrary\temp_end_coords.csv'
gdb = r'C:\Testing\test2.gdb'
SR = 3418 # Factory code for state plane Iowa South

# Get coords list as a tuple
coords = []
with open(csv, 'r') as r:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for line in r.readlines()[1:]: # skip headers
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; coords.append(tuple(float(i) for i in line.split(',')[1:3]))

# Create new feature class
fc = arcpy.CreateFeatureclass_management(gdb, 'Points_test','POINT',spatial_reference=SR)
with arcpy.da.InsertCursor(fc, ['SHAPE@']) as irows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for cord in coords:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; irows.insertRow((cord,))
print 'Done'
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 01:18:59 GMT</pubDate>
    <dc:creator>SeanWray</dc:creator>
    <dc:date>2021-12-12T01:18:59Z</dc:date>
    <item>
      <title>How can I create points from attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-create-points-from-attributes/m-p/589318#M33274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have created a shp file in ArcCatalog and prepopulted my x y data. Now I want to calculate the Shape field based on my x y values. I used to use the code below, but now it doesn't work. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(I know how to add as a table, display XY, and then convert. It seems to me there should be a shorter way to do this)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a python replacement?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pPoint As IPoint &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Set pPoint = [Shape] &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pPoint.X = [Long] &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pPoint.Y = [Lat] &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Enter the following in the box under 'Shape = ': &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;pPoint&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Jun 2013 16:48:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-create-points-from-attributes/m-p/589318#M33274</guid>
      <dc:creator>SeanWray</dc:creator>
      <dc:date>2013-06-20T16:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: How can I create points from attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-create-points-from-attributes/m-p/589319#M33275</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;&lt;SPAN&gt;How did you get your coordinates?&amp;nbsp; You could use arcpy &lt;A href="&amp;lt;/span&amp;gt;&amp;lt;a" target="_blank" rel="nofollow noopener noreferrer"&gt;point" rel="nofollow" target="_blank"&amp;gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//018z0000006t000000]point&lt;/A&gt;&lt;SPAN&gt; geometry or an &lt;A href="&amp;lt;/span&amp;gt;&amp;lt;a" target="_blank" rel="nofollow noopener noreferrer"&gt;insert" rel="nofollow" target="_blank"&amp;gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//018w0000000t000000]insert&lt;/A&gt;&lt;SPAN&gt; cursor to build your point feature class.&amp;nbsp; Here is an example of how you can do this by reading x,y coords from a csv and making a point feature class.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is what the csv looks like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Line_ID,X_Coord,Y_Coord,Length,NAME1,JOIN_FID,Type&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1,2317355.49962,681731.016618,1315.40287879,SPICER AVENUE,1,Start&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2,2317485.73951,676450.010776,5316.04898921,SPICER AVENUE,2,Start&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3,2317627.9246,671135.874095,5294.36015714,190TH STREET,3,Start&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4,2317355.49962,681731.016618,5376.75305576,170TH STREET,4,Start&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I just split this list by commas to get the 2nd and third columns which are the x and y coordinates and created a tuple for the shape field.&amp;nbsp; Here is how it can be done in 10.1.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
arcpy.env.overwriteOutput = True


# Coords stored in a csv
csv = r'G:\PROJECTS\Cedar\GeneralScripts\PyLibrary\temp_end_coords.csv'
gdb = r'C:\Testing\test2.gdb'
SR = 3418 # Factory code for state plane Iowa South

# Get coords list as a tuple
coords = []
with open(csv, 'r') as r:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for line in r.readlines()[1:]: # skip headers
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; coords.append(tuple(float(i) for i in line.split(',')[1:3]))

# Create new feature class
fc = arcpy.CreateFeatureclass_management(gdb, 'Points_test','POINT',spatial_reference=SR)
with arcpy.da.InsertCursor(fc, ['SHAPE@']) as irows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for cord in coords:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; irows.insertRow((cord,))
print 'Done'
&lt;/PRE&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:18:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-create-points-from-attributes/m-p/589319#M33275</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T01:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: How can I create points from attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-create-points-from-attributes/m-p/589320#M33276</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I manually entered the coords in the attribute table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;How did you get your coordinates?&amp;nbsp; You could use arcpy &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018z0000006t000000" target="_blank" rel="nofollow noopener noreferrer"&gt;point geometry&lt;/A&gt; or an &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018w0000000t000000" target="_blank" rel="nofollow noopener noreferrer"&gt;insert cursor&lt;/A&gt; to build your point feature class.&amp;nbsp; Here is an example of how you can do this by reading x,y coords from a csv and making a point feature class.&lt;BR /&gt;&lt;BR /&gt;This is what the csv looks like:&lt;BR /&gt;&lt;BR /&gt;Line_ID,X_Coord,Y_Coord,Length,NAME1,JOIN_FID,Type&lt;BR /&gt;1,2317355.49962,681731.016618,1315.40287879,SPICER AVENUE,1,Start&lt;BR /&gt;2,2317485.73951,676450.010776,5316.04898921,SPICER AVENUE,2,Start&lt;BR /&gt;3,2317627.9246,671135.874095,5294.36015714,190TH STREET,3,Start&lt;BR /&gt;4,2317355.49962,681731.016618,5376.75305576,170TH STREET,4,Start&lt;BR /&gt;&lt;BR /&gt;I just split this list by commas to get the 2nd and third columns which are the x and y coordinates and created a tuple for the shape field.&amp;nbsp; Here is how it can be done in 10.1.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
arcpy.env.overwriteOutput = True


# Coords stored in a csv
csv = r'G:\PROJECTS\Cedar\GeneralScripts\PyLibrary\temp_end_coords.csv'
gdb = r'C:\Testing\test2.gdb'
SR = 3418 # Factory code for state plane Iowa South

# Get coords list as a tuple
coords = []
with open(csv, 'r') as r:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for line in r.readlines()[1:]: # skip headers
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; coords.append(tuple(float(i) for i in line.split(',')[1:3]))

# Create new feature class
fc = arcpy.CreateFeatureclass_management(gdb, 'Points_test','POINT',spatial_reference=SR)
with arcpy.da.InsertCursor(fc, ['SHAPE@']) as irows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for cord in coords:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; irows.insertRow((cord,))
print 'Done'
&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:18:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-create-points-from-attributes/m-p/589320#M33276</guid>
      <dc:creator>SeanWray</dc:creator>
      <dc:date>2021-12-12T01:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: How can I create points from attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-create-points-from-attributes/m-p/589321#M33277</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;I manually entered the coords in the attribute table.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Well that doesn't sound like fun....Ok, since you already have the points in that table, you can read them into point geometry objects to create a new point feature class.&amp;nbsp; I did not know if you are using ArcGIS 10 or 10.1 so this would be the 10.0 version to be safe.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy, os
arcpy.env.overwriteOutput = True

def CreatePoints(in_table, x_field, y_field, output, SR):

&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create new feature class
&amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.Exists(output):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management(output)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CreateFeatureclass_management(os.path.dirname(output),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; os.path.basename(output),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'POINT',spatial_reference=SR)
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Get coords list 
&amp;nbsp;&amp;nbsp;&amp;nbsp; irows = arcpy.InsertCursor(output)
&amp;nbsp;&amp;nbsp;&amp;nbsp; rows = arcpy.SearchCursor(in_table)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for srow in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = srow.getValue(x_field)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = srow.getValue(y_field)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; point = arcpy.Point(x,y)

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Insert point objects into shape field
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row = irows.newRow()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.Shape = point
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; irows.insertRow(row)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'Done'

if __name__ == '__main__':

&amp;nbsp;&amp;nbsp;&amp;nbsp; in_table = r'C:\Testing\test2.gdb\Roads_Points2'
&amp;nbsp;&amp;nbsp;&amp;nbsp; x_field = 'X_Coord'
&amp;nbsp;&amp;nbsp;&amp;nbsp; y_field = 'Y_Coord'
&amp;nbsp;&amp;nbsp;&amp;nbsp; output = r'C:\Testing\test2.gdb\Roads_Points3'
&amp;nbsp;&amp;nbsp;&amp;nbsp; SR = 3418 # Factory code for state plane Iowa South

&amp;nbsp;&amp;nbsp;&amp;nbsp; CreatePoints(in_table, x_field, y_field, output, SR)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You will need to change the variables under the if name = main part.&amp;nbsp; If you do have ArcGIS 10.0 you will need to find the full path to the .prj file for the SR parameter.&amp;nbsp; Otherwise, if using 10.1 you can just supply a factory code like I did.&amp;nbsp; Obviously the output would be the new point feature class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Of course, you could always skip all this and do the make xy event table, but your original question was how to do something like this in Python instead so the above code should work for you.&amp;nbsp; Good luck!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:19:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-create-points-from-attributes/m-p/589321#M33277</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T01:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: How can I create points from attributes?</title>
      <link>https://community.esri.com/t5/data-management-questions/how-can-i-create-points-from-attributes/m-p/589322#M33278</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Sean, here's how you do it using the Calculate Field tool in 10.x.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Field: &lt;STRONG&gt;Shape&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Expression:&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14134423001122880" jivemacro_uid="_14134423001122880" modifiedtitle="true"&gt;
&lt;P&gt;&lt;SPAN style="color: rgba(0, 0, 0, 0); font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;pointMove&lt;/SPAN&gt;(!SHAPE@!, !XNEW!, !YNEW!)&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, sans-serif;"&gt;Code Block:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14134422646301061 jive_text_macro" jivemacro_uid="_14134422646301061" modifiedtitle="true"&gt;
&lt;P&gt;def pointMove(shape, x_value, y_value): &lt;/P&gt;
&lt;P&gt;&amp;nbsp; point = shape.getPart(0) &lt;/P&gt;
&lt;P&gt;&amp;nbsp; point.X = x_value &lt;/P&gt;
&lt;P&gt;&amp;nbsp; point.Y = y_value &lt;/P&gt;
&lt;P&gt;&amp;nbsp; return point&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt; Parser: &lt;STRONG&gt;PYTHON_9.3&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Oct 2014 06:52:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/data-management-questions/how-can-i-create-points-from-attributes/m-p/589322#M33278</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2014-10-16T06:52:59Z</dc:date>
    </item>
  </channel>
</rss>

