<?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: gp.InsertCursor method (ArcGIS 9.3) in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/gp-insertcursor-method-arcgis-9-3/m-p/477679#M37401</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is not the way to make a subset of features, although with some editing and additions it would be possible. You cannot get a geometry object from a cursor without extracting each vertex to make a new object, you do not need to get area and perimeter because they are geometry properties.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;MakeFeatureLayer_management will create a layer using your definition similar to the cursor, but it will be an in memory bitmap that you do not need to access.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Copy_management will take the featurelayer and create a new featureclass of the subset.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcgisscripting, sys
gp = arcgisscripting.create(9.3)
getzip = sys.argv[1]

gp.Workspace = "C:\\Student\\PYTH\\Database\\MySD.mdb"

gp.MakeFeatureLayer_management ("Zipcodes", "Ziplayer","[ZIP] = %d" % int(getzip))
gp.Copy_management("Ziplayer","Polyblank")
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 21:06:11 GMT</pubDate>
    <dc:creator>KimOllivier</dc:creator>
    <dc:date>2021-12-11T21:06:11Z</dc:date>
    <item>
      <title>gp.InsertCursor method (ArcGIS 9.3)</title>
      <link>https://community.esri.com/t5/python-questions/gp-insertcursor-method-arcgis-9-3/m-p/477678#M37400</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi, I'm learning to script and have been experimenting with 'cursors'.&amp;nbsp; I keep getting an error at the command prompt:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"rowc.Shape=geom&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RuntimeError: ERROR 999999: Error executing function.&amp;nbsp; The coordinates or measures are out of bounds."&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;By accident I found a workaround but I don't understand why it works and think I shouldn't need it.&amp;nbsp; I create two varibles to store the polygon.Extent and polygon.Area fields from a feature class that I wish to copy over to another feature class.&amp;nbsp; I run a gp.Search.Cursor first to find the polygons containing the ZIPCODE to copy. The ZIPCODE argument is retrieved using sys.argv[1] from the command prompt.&amp;nbsp; I copy the polygon.Shape which I understand encapsulates the area and extent fields within the geoprocessor.&amp;nbsp; Ayhow, I get the above error message when I attempt to do that.&amp;nbsp; I then figured I needed to copy the Area and Extent fields and Insert those attributes as well.&amp;nbsp; After I created the varibles to store the Area and Extent I forgot to Insert them, but it worked!&amp;nbsp; I tried 'commenting' those varibles back out and get the error.&amp;nbsp; Then I 'uncomment' the varibles back in and behold, it works!&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I used some unconventional terms or names its because I'm new.&amp;nbsp; Sorry, my indentation gets removed when I post.&amp;nbsp; Thanks for any feedback!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Below is my entire program:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcgisscripting, sys&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gp = arcgisscripting.create(9.3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;getzip = sys.argv[1]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;gp.Workspace = "C:\\Student\\PYTH\\Database\\MySD.mdb"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;cur = gp.SearchCursor ("Zipcodes", "[ZIP] = %d" % int(getzip))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#search for polygons based on a zipcode entered as an argument&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;listID=[]&amp;nbsp; # store a list of objectid(s) for zipcodes that have numerous polygons&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rowa = cur.Next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;counter = 0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while rowa:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; listID+=[rowa.OBJECTID]&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; counter +=1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rowa=cur.Next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print '%d polygon(s) counted so found meeting criteria' % counter&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print 'The&amp;nbsp; OBJECTID(s) are... ', listID&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#search for and save the geometry of each feature with an objectid saved in listID above&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for x in listID:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur = gp.SearchCursor("Zipcodes", "[OBJECTID] = %d" %x)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rowb=cur.Next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; geom=rowb.Shape&amp;nbsp;&amp;nbsp; # i believe this line should store the entire geometry&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; geoA=geom.Area&amp;nbsp;&amp;nbsp; # error -999999 if I comment this line out&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; geoX=geom.Extent&amp;nbsp;&amp;nbsp; # error - 999999 if I comment this line out&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur=gp.InsertCursor("polyBlank")&amp;nbsp;&amp;nbsp; #&amp;nbsp; insert the geometry and zipcode into a new feature class&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rowc=cur.NewRow()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rowc.Shape=geom&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; rowc.ZIP=getzip&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cur.InsertRow(rowc)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "added polygon ", x&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del cur&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 21 Feb 2011 15:41:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/gp-insertcursor-method-arcgis-9-3/m-p/477678#M37400</guid>
      <dc:creator>MarkWiygul</dc:creator>
      <dc:date>2011-02-21T15:41:09Z</dc:date>
    </item>
    <item>
      <title>Re: gp.InsertCursor method (ArcGIS 9.3)</title>
      <link>https://community.esri.com/t5/python-questions/gp-insertcursor-method-arcgis-9-3/m-p/477679#M37401</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is not the way to make a subset of features, although with some editing and additions it would be possible. You cannot get a geometry object from a cursor without extracting each vertex to make a new object, you do not need to get area and perimeter because they are geometry properties.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;MakeFeatureLayer_management will create a layer using your definition similar to the cursor, but it will be an in memory bitmap that you do not need to access.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Copy_management will take the featurelayer and create a new featureclass of the subset.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcgisscripting, sys
gp = arcgisscripting.create(9.3)
getzip = sys.argv[1]

gp.Workspace = "C:\\Student\\PYTH\\Database\\MySD.mdb"

gp.MakeFeatureLayer_management ("Zipcodes", "Ziplayer","[ZIP] = %d" % int(getzip))
gp.Copy_management("Ziplayer","Polyblank")
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:06:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/gp-insertcursor-method-arcgis-9-3/m-p/477679#M37401</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2021-12-11T21:06:11Z</dc:date>
    </item>
  </channel>
</rss>

