<?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: Add Feature to Feature Class Using Python Scripting in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/add-feature-to-feature-class-using-python/m-p/522818#M40993</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Carly,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;please note, the example provided by Josh is for arcmap 10.1 or 10.2 only. If you are on version 10.0, you will need to use this: &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help../index.html#//000v00000038000000"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help../index.html#//000v00000038000000&lt;/A&gt;&lt;SPAN&gt;. There is slightly different syntax between the arcpy.&lt;/SPAN&gt;&lt;STRONG&gt;da&lt;/STRONG&gt;&lt;SPAN&gt;.InsertCursor (10.1), and the arcpy.InsertCursor (10.0, no da). I am not very familiar with 10.0 insert cursors, so I'm sorry if you are using 10.0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;in answer to your questions:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. The Counties feature class would need to have a field called "NAME" in that example. The "SHAPE@XY" thing is referring to the shape field. Which all feature classes have by default. From the syntax in that example, we are able to tell that the "counties" feature class is a point feature class, because it simply uses a tuple in the form of (x, y). We'll save lines or polygons for another time &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. "SHAPE@XY" usually refers to the centroid. But i think because it is a point feature, this is the same as the coordinates of the point. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. When using the insert cursor, it is not necessary to call all of the fields, only the fields you wish to change the value of. In the example, the counties feature class could have more fields than listed, but they are only updating the "name" field, and the shape, so these are the ones that were called. So if you only want to plot a point, no attributes, you could just list ("SHAPE@XY") as the second parameter. Then below where it says c.insertRow(row), you could simply put "c.insertRow((x, y))". The double brackets is because the (x,y) needs to be a tuple.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4. yes. You just need to set your coordinate system of your layer as decimal degrees.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-----&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now, in regards to user input by clicking, I have tried doing this sort of thing before.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;May I suggest you use a "feature set" - &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/A_quick_tour_of_using_Feature_Set_and_Record_Set/002w00000023000000/"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#/A_quick_tour_of_using_Feature_Set_and_Record_Set/002w00000023000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is set up in model builder (and then you can export from model builder to python script if you want to do it that way).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Open model builder, and drag the buffer tool into it from toolbox.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Right-click anywhere in a model and choose Create Variable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Scroll down the list and choose Feature Set &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-connect the feature set to the buffer tool and set it as input&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I believe there are additional steps, like needing to export it as a tool, but this should get you started.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Jan 2014 01:10:30 GMT</pubDate>
    <dc:creator>AndrewHaley</dc:creator>
    <dc:date>2014-01-21T01:10:30Z</dc:date>
    <item>
      <title>Add Feature to Feature Class Using Python Scripting</title>
      <link>https://community.esri.com/t5/python-questions/add-feature-to-feature-class-using-python/m-p/522815#M40990</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am a GIS Analyst and I am extremely new to Python scripting. I need to take input from a mouse click in ArcMap and then create a buffer around that point. Creating the buffer is simple, but using the location of that point as the input for the arcpy.Buffer_analysis call is tripping me up. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;My initial thought was to take the location of the click and actually digitize a point there by adding the point feature to a feature class, and then use that feature class as the input for the buffer. That is the way that I would do it in ArcMap, and it would be quite simple. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is it possible to add a feature to a feature class using a Python script?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is it possible to gather xy input from a mouse click?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a better way to acheive my goal?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help is greatly appreciated!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jan 2014 13:06:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-feature-to-feature-class-using-python/m-p/522815#M40990</guid>
      <dc:creator>CarlyFrazier</dc:creator>
      <dc:date>2014-01-20T13:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: Add Feature to Feature Class Using Python Scripting</title>
      <link>https://community.esri.com/t5/python-questions/add-feature-to-feature-class-using-python/m-p/522816#M40991</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Carly,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;First off, there is an easy way to add features to a feature class with python. See &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018w0000000t000000"&gt;insert cursor&lt;/A&gt;&lt;SPAN&gt;. There is some sample code at the bottom of the linked page, but feel free to ask if you hit a wall.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Getting the coordinates of a mouse-click is a little more complicated. As far as I know you would have to create a &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//014p00000025000000"&gt;python add-in&lt;/A&gt;&lt;SPAN&gt; tool. The python add-ins are for 10.1 and up. They are a little hard to set up, but as long as you follow &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/project/014p00000022000000/"&gt;ESRI's instructions&lt;/A&gt;&lt;SPAN&gt;, you should be fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When you're creating the tool, you'll want to use &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/Tool/014p00000027000000/"&gt;onMouseDownMap and onMouseUpMap&lt;/A&gt;&lt;SPAN&gt; to retrieve a map coordinate from the user.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Once you're done creating your python add-in it is really easy to distribute it to a bunch of arcmap users.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Alternatively (if you wanted to avoid the whole python add-in thing), you could require the user to provide a lat and long manually, or provide a point feature class with only one point in it (which you could verify in python).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Whatever you choose, I'm sure we can provide help as you work through it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Good luck!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;~Josh&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jan 2014 13:46:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-feature-to-feature-class-using-python/m-p/522816#M40991</guid>
      <dc:creator>JoshuaChisholm</dc:creator>
      <dc:date>2014-01-20T13:46:41Z</dc:date>
    </item>
    <item>
      <title>Re: Add Feature to Feature Class Using Python Scripting</title>
      <link>https://community.esri.com/t5/python-questions/add-feature-to-feature-class-using-python/m-p/522817#M40992</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks so much, John. This is great so far! &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've decided to start with taking user input of the coordinates, and then plotting the point from there. Making an add-in seems more difficult, so I think I'll work up to it. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have figured out how to create my point feature class and take X and Y input from the user. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Could you walk me through adding a point to that feature class based upon an XY value, or decimal degree values? I trying to use this sample code, and edit it to fit my script, but I've got some questions about it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Does the 'counties' feature class already have fields called "NAME" and "SHAPE@XY"? I understand how to add a field called "NAME", but I don't understand how to add a special field that ArcMap will know to plot the point from.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. I'm assuming that the "SHAPE@XY" token is used to plot the point at the XY coordinates, but I don't understand how tokens work?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. What parameters are acceptable for cursor.insertRow()? Do I need to loop through a list? That seems unnessecary because I only need one point.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4. Is it possible to plot the point based on decimal degrees?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;import arcpy&lt;BR /&gt;&lt;BR /&gt;# A list of values that will be used to construct new rows&lt;BR /&gt;#&lt;BR /&gt;row_values = [('Anderson', (1409934.4442000017, 1076766.8192000017)),&lt;BR /&gt;&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; ('Andrews', (752000.2489000037, 1128929.8114))]&lt;BR /&gt;&lt;BR /&gt;# Open an InsertCursor&lt;BR /&gt;#&lt;BR /&gt;cursor = arcpy.da.InsertCursor("C:/data/texas.gdb/counties",&lt;BR /&gt;&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; ("NAME", "SHAPE@XY"))&lt;BR /&gt;&lt;BR /&gt;# Insert new rows that include the county name and a x,y coordinate&lt;BR /&gt;#&amp;nbsp; pair that represents the county center&lt;BR /&gt;#&lt;BR /&gt;for row in row_values:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cursor.insertRow(row)&lt;BR /&gt;&lt;BR /&gt;# Delete cursor object&lt;BR /&gt;#&lt;BR /&gt;del cursor&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, is it possible to take user input directly from the Python window in ArcMap?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for bearing with me, I'm about as green as they come in Python &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jan 2014 18:52:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-feature-to-feature-class-using-python/m-p/522817#M40992</guid>
      <dc:creator>CarlyFrazier</dc:creator>
      <dc:date>2014-01-20T18:52:05Z</dc:date>
    </item>
    <item>
      <title>Re: Add Feature to Feature Class Using Python Scripting</title>
      <link>https://community.esri.com/t5/python-questions/add-feature-to-feature-class-using-python/m-p/522818#M40993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Carly,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;please note, the example provided by Josh is for arcmap 10.1 or 10.2 only. If you are on version 10.0, you will need to use this: &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help../index.html#//000v00000038000000"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help../index.html#//000v00000038000000&lt;/A&gt;&lt;SPAN&gt;. There is slightly different syntax between the arcpy.&lt;/SPAN&gt;&lt;STRONG&gt;da&lt;/STRONG&gt;&lt;SPAN&gt;.InsertCursor (10.1), and the arcpy.InsertCursor (10.0, no da). I am not very familiar with 10.0 insert cursors, so I'm sorry if you are using 10.0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;in answer to your questions:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. The Counties feature class would need to have a field called "NAME" in that example. The "SHAPE@XY" thing is referring to the shape field. Which all feature classes have by default. From the syntax in that example, we are able to tell that the "counties" feature class is a point feature class, because it simply uses a tuple in the form of (x, y). We'll save lines or polygons for another time &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. "SHAPE@XY" usually refers to the centroid. But i think because it is a point feature, this is the same as the coordinates of the point. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3. When using the insert cursor, it is not necessary to call all of the fields, only the fields you wish to change the value of. In the example, the counties feature class could have more fields than listed, but they are only updating the "name" field, and the shape, so these are the ones that were called. So if you only want to plot a point, no attributes, you could just list ("SHAPE@XY") as the second parameter. Then below where it says c.insertRow(row), you could simply put "c.insertRow((x, y))". The double brackets is because the (x,y) needs to be a tuple.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4. yes. You just need to set your coordinate system of your layer as decimal degrees.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-----&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now, in regards to user input by clicking, I have tried doing this sort of thing before.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;May I suggest you use a "feature set" - &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/A_quick_tour_of_using_Feature_Set_and_Record_Set/002w00000023000000/"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#/A_quick_tour_of_using_Feature_Set_and_Record_Set/002w00000023000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is set up in model builder (and then you can export from model builder to python script if you want to do it that way).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Open model builder, and drag the buffer tool into it from toolbox.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Right-click anywhere in a model and choose Create Variable.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Scroll down the list and choose Feature Set &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-connect the feature set to the buffer tool and set it as input&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I believe there are additional steps, like needing to export it as a tool, but this should get you started.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Jan 2014 01:10:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-feature-to-feature-class-using-python/m-p/522818#M40993</guid>
      <dc:creator>AndrewHaley</dc:creator>
      <dc:date>2014-01-21T01:10:30Z</dc:date>
    </item>
  </channel>
</rss>

