<?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: Issue with Copy Features in Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595070#M46614</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is still a potential risk in this code. If you loop through the points to create a where clause with your Object ID, you assume that the values of the ObjectID is a range without gaps in its values. This might be the case, but if you edit the featureclass and delete a feature, it will no longer be the case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To create a more stable way you could use something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14075209603841950" jivemacro_uid="_14075209603841950"&gt;
&lt;P&gt;fc_pnts = "C:/Users/Ryan/Documents/arcgis_folder/sitetwoworkarea.gdb/route_one_points"&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# determine the ObjectID field name&lt;/P&gt;
&lt;P&gt;fld_oid = arcpy.Describe(fc_pnts).OIDFieldName&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# make a list of all the ObjectID's in the featureclass&lt;/P&gt;
&lt;P&gt;lst_oid = [row[0] for row in arcpy.da.SeachCursor(fc_pnts, ("OID@"))]&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# loop through oid's and create the where clause&lt;/P&gt;
&lt;P&gt;for oid in lst_oid:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where = "{0} = {1}".format(arcpy.AddFieldDelimiters(fc_pnts, fld_oid), oid)&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 08 Aug 2014 18:03:00 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2014-08-08T18:03:00Z</dc:date>
    <item>
      <title>Issue with Copy Features in Python</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595057#M46601</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm fairly new to writing scripts in python.&amp;nbsp; I'm creating one to take a feature class of about 100 points and turn it into individual points then run a cost path analysis on each of them.&amp;nbsp; The cost rasters and backlink rasters are already created.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem with the script is that it will create the individual points, but they won't work with the rest of the script that creates the cost paths while it's running.&amp;nbsp; If the script stops running and restarts with the section of code commented out to create the points, it will run the cost paths on the points it created the last time it ran.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; number_of_points = int(arcpy.GetCount_management("route_one_points").getOutput(0))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print number_of_points
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while i &amp;lt;= number_of_points:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "testing"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print i&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; pointname = "route_one_point" + str(i)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management("route_one_points", pointname)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(pointname, "NEW_SELECTION", "OBJECTID = %s" % i)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management("route_one_point" + str(i), "route_one_point" + str(i))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print pointname
&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; outCostPath = arcpy.sa.CostPath(pointname, "route_one_cost", "route_one_backlink")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outCostPath.save("route_one_point" + str(i) + "_path")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i += 1

&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm pretty sure the problem is in Copy Features.&amp;nbsp; The script will recognize the features exist, but gives this error message:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcgisscripting.ExecuteError: ERROR 010045: COSTPATH: The number of FROM cells is 0.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 010067: Error in executing grid expression.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Again, if I run it with the costpath lines commented out, it will run fine.&amp;nbsp; If I rerun it with the lines making the points commented out, it will run fine and create the costpaths.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The whole thing has to run in one go, so I can't just create 2 separate scripts and run them one at a time unfortunately.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any suggestions on how to solve this problem?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 21 Jun 2014 23:38:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595057#M46601</guid>
      <dc:creator>ryank</dc:creator>
      <dc:date>2014-06-21T23:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Copy Features in Python</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595058#M46602</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;reformat your code using code blocks so that indentation can be checked&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Jun 2014 02:38:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595058#M46602</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2014-06-22T02:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Copy Features in Python</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595059#M46603</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is that what you're looking for?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Jun 2014 04:53:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595059#M46603</guid>
      <dc:creator>ryank</dc:creator>
      <dc:date>2014-06-22T04:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Copy Features in Python</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595060#M46604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;you should try to explicitly set the overwrite ability to be true and specify a working folder (env settings) so that the output file will be created in a particular (alternately, specify a full path and filename)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 22 Jun 2014 08:11:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595060#M46604</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2014-06-22T08:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Copy Features in Python</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595061#M46605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I already did.&amp;nbsp; I didn't add those sections because I didn't believe it was relevant to this particular problem, and this section of code is going to be added to another much larger section.&amp;nbsp; It's just a bunch of extra stuff, but if you think the problem might be somewhere else in the code.&amp;nbsp; This is everything that runs in this script.&amp;nbsp; The commented out sections that all start with "arcpy" are not going to be commented out.&amp;nbsp; I was just running it to make sure the point features actually can run.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# cost paths tests

import sys, string, os, arcgisscripting, arcpy, datetime, time, math
arcpy.CheckOutExtension("Spatial")

#CostPath (in_destination_data, in_cost_distance_raster, in_cost_backlink_raster, {path_type}, {destination_field})
#route_one

arcpy.env.workspace = "C:/Users/Ryan/Documents/arcgis_folder/sitetwoworkarea.gdb"
#arcpy.env.workspace = "C:\Users\Ryan\Desktop\GIS\python\project_test\project_test_gdb.gdb"

#script will overwrite existing data

arcpy.env.overwriteOutput = 1


begin = datetime.datetime.now ()
start = time.clock ()
loopcounter = 0
raster_list = arcpy.ListRasters()


print raster_list
#def create_cost_paths():
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print "I'm making the route cost."
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #i = 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #number_of_points = int(arcpy.GetCount_management("route_one_points").getOutput(0))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print number_of_points
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #loopcounter = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #while i &amp;lt;= number_of_points:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print "testing"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print i&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; #pointname = "route_one_point" + str(i)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #arcpy.MakeFeatureLayer_management("route_one_points", pointname)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #arcpy.SelectLayerByAttribute_management(pointname, "NEW_SELECTION", "OBJECTID = %s" % i)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #arcpy.CopyFeatures_management("route_one_point" + str(i), "route_one_point" + str(i))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #print pointname
&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; ##outCostPath = arcpy.sa.CostPath(pointname, "route_one_cost", "route_one_backlink")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ##outCostPath.save("route_one_point" + str(i) + "_path")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #i += 1
def create_cost_paths():
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "I'm making the route cost."
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; number_of_points = int(arcpy.GetCount_management("route_one_points").getOutput(0))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print number_of_points
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; loopcounter = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while i &amp;lt;= number_of_points:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "testing"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print i&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; pointname = "route_one_point" + str(i)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #arcpy.MakeFeatureLayer_management("route_one_points", pointname)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #arcpy.SelectLayerByAttribute_management(pointname, "NEW_SELECTION", "OBJECTID = %s" % i)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #arcpy.CopyFeatures_management("route_one_point" + str(i), "route_one_point" + str(i))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print pointname
&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; outCostPath = arcpy.sa.CostPath(pointname, "route_one_cost", "route_one_backlink")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outCostPath.save("route_one_point" + str(i) + "_path")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i += 1

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i = 1


def test():
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outCostPath = arcpy.sa.CostPath("route_one_point1", "route_one_cost", "route_one_backlink")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; outCostPath.save("route_one_point1_path")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
create_cost_paths()




print "I started at " + str(begin.hour) + ":" + str(begin.minute) 
print "I took " + str(int((time.clock() - start) / 3600)) + " hours and " + str((int(time.clock() - start) / 60 ) % 60) + " minutes to finish"
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:33:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595061#M46605</guid>
      <dc:creator>ryank</dc:creator>
      <dc:date>2021-12-12T01:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Copy Features in Python</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595062#M46606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;A couple things:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You test the count of features in the input fc using GetCount_management,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;why not test the output too?. You can test both the layer and the new fc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why do you make a layer, make a selection, make a fc?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Why not just make a layer with your selection where clause&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and pass the layer to CostPath?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Help for Cost Path says it takes an input feature layer, not a feature class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I agree that you should also explicitly handle your layers and FCs with full paths&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and an explicit " if Exists: Delete " function...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT:&amp;nbsp; very good point from Dallas (below); to wit:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;iterate through the cursor, don't rely on a separate counter, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and feature IDs are internally set: they can be useful, but Arc puts them there&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for its own benefit, not yours...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jun 2014 10:54:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595062#M46606</guid>
      <dc:creator>markdenil</dc:creator>
      <dc:date>2014-06-23T10:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Copy Features in Python</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595063#M46607</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for the long response.&amp;nbsp; A lot came up with the reserves this last month.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I set up a count so I can set up a try/except later.&amp;nbsp; I use it in a similar loop and it works out pretty well.&amp;nbsp; If I don't use a separate counter, it can't keep track of both the iteration and which point is being run.&amp;nbsp; At least I don't know enough about running cursors to do so.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I don't include the MakeFeatureLayer it throws this error&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;
&lt;P&gt;arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.&lt;/P&gt;
&lt;P&gt;The value cannot be a feature class&lt;/P&gt;

&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The help for the Select Layer By Attribute scripting gives this as the example for performing this process&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;
&lt;P&gt;# Name: ExtactFeaturesByLocationAndAttribute.py&lt;/P&gt;
&lt;P&gt;# Description: Extract features to a new feature class based on a spatial relationships to another layer AND an attribute query&lt;/P&gt;
&lt;P&gt;# Author: ESRI&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# Import system modules&lt;/P&gt;
&lt;P&gt;import arcpy&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# Set the workspace&lt;/P&gt;
&lt;P&gt;env.workspace = "c:/data/mexico.gdb"&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# Make a layer from the feature class&lt;/P&gt;
&lt;P&gt;arcpy.MakeFeatureLayer_management("cities", "lyr") &lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# Select all cities which overlap the chihuahua polygon&lt;/P&gt;
&lt;P&gt;arcpy.SelectLayerByLocation_management("lyr", "intersect", "chihuahua", 0, "new_selection")&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# Within selected features, further select only those cities which have a population &amp;gt; 10,000&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;arcpy.SelectLayerByAttribute_management("lyr", "SUBSET_SELECTION", ' "population" &amp;gt; 10000 ')&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# Write the selected features to a new featureclass&lt;/P&gt;
&lt;P&gt;arcpy.CopyFeatures_management("lyr", "chihuahua_10000plus")&lt;/P&gt;
&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm mostly using their example as a startpoint for this.&amp;nbsp; I'm perfectly willing to try something else, but again keep in mind I'm pretty new to this.&amp;nbsp; I'm not sure if that's what you meant when you asked why I go through that.&amp;nbsp; And I'm not sure how to pass the where clause straight to the costpath, but I also need to keep each point individually, because each point is going to be used later.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;
&lt;P&gt;The Help for Cost Path says it takes an input feature layer, not a feature class.&lt;/P&gt;
&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The thing is, it will accept the output if I run the cost path in another script.&amp;nbsp; I'm not sure if that matters.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't see a post by Dallas.&amp;nbsp; Mark Denil's post is the last I can see.&amp;nbsp; Are there other posts?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 01:58:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595063#M46607</guid>
      <dc:creator>ryank</dc:creator>
      <dc:date>2014-08-07T01:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Copy Features in Python</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595064#M46608</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ryan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just looking over the Bulk of the scipt and have questions:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14074150267527847 jive_text_macro" jivemacro_uid="_14074150267527847" modifiedtitle="true"&gt;
&lt;P&gt;arcpy.env.workspace = "SET TO A GDB"&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;You have your environment set to a GDB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_1407416397168688 jive_text_macro" jivemacro_uid="_1407416397168688" modifiedtitle="true"&gt;raster_list = arcpy.ListRasters()&lt;/PRE&gt;&lt;P&gt;Listing Rasters from the environment.&lt;/P&gt;&lt;P&gt;I don't think you going to get a list of Rasters, they are stored in Raster Datasets within a GDB.&lt;/P&gt;&lt;P&gt;When i Print the list it is NONE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The environment should be set to a folder where the Rasters are stored.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14074169301059333" jivemacro_uid="_14074169301059333" modifiedtitle="true"&gt;def create_cost_paths(**ARGUMENTS**):&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="color: #303030; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px;"&gt;Your create_cost_paths() function has no Arguments()&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So when you set variables referenced to "route_one_cost" (RASTER) it doesn't reference anything. It doesn't find anything.&lt;/P&gt;&lt;P&gt;This is because you carry nothing into in the function from the environment or list from the environment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can fix this be either taking your &lt;STRONG&gt;arcpy.env.workspace&lt;/STRONG&gt; and moving it into the function, or you can add the LIST from the environment as argument for the function that uses it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 13:16:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595064#M46608</guid>
      <dc:creator>ToddUlery</dc:creator>
      <dc:date>2014-08-07T13:16:43Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Copy Features in Python</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595065#M46609</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;
&lt;P&gt;I don't think you going to get a list of Rasters, they are stored in Raster Datasets within a GDB.&lt;/P&gt;
&lt;P&gt;When i Print the list it is NONE.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;The environment should be set to a folder where the Rasters are stored.&lt;/P&gt;
&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Again, I'm new to python, but wouldn't it return none for you no matter what since you don't have the rasters?&amp;nbsp; When I print the list it does return the rasters, even when I place print code inside the function.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 16:42:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595065#M46609</guid>
      <dc:creator>ryank</dc:creator>
      <dc:date>2014-08-07T16:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Copy Features in Python</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595066#M46610</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Both your original feature layer you create and your feature class have the same name, pointname ( or "route_one_point" + str(i)). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; I'm assuming you want to use your feature class you created, so perhaps give your feature class a different name than your feature layer and run again(say pointname + "fc").&amp;nbsp; It might be trying to run the tool off feature layer you made first, instead of the feature class with only one point.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, since you already made a variable for pointname = "route_one_point" + str(i), hardcoding in "route_one_point" + str(i) again and again is a bit wasteful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 17:17:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595066#M46610</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2014-08-07T17:17:19Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Copy Features in Python</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595067#M46611</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are correct, but I have raster datasets inside another GDB that i am using to test with.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What are you setting for your env?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I feel like your env, is not set to a GDB. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 17:32:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595067#M46611</guid>
      <dc:creator>ToddUlery</dc:creator>
      <dc:date>2014-08-07T17:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Copy Features in Python</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595068#M46612</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That worked, Ian.&amp;nbsp; I can't believe it, it seems kinda obvious, but I've been looking at this off and on for 2 months, two people I go to school with have been looking at it, and 4 people on here did.&amp;nbsp;&amp;nbsp; And like almost every huge problem, it turns out to be something obvious.&amp;nbsp; &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/silly.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 19:20:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595068#M46612</guid>
      <dc:creator>ryank</dc:creator>
      <dc:date>2014-08-07T19:20:21Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Copy Features in Python</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595069#M46613</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Another reason to use variables more effectively.&amp;nbsp; If you had used your variable in ever place you spelled out its value, I bet it would have been caught a little sooner, since it would have been more apparent ot the eye that you were using the same string for each. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Glad you got it working properly. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 Aug 2014 20:20:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595069#M46613</guid>
      <dc:creator>IanMurray</dc:creator>
      <dc:date>2014-08-07T20:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with Copy Features in Python</title>
      <link>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595070#M46614</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is still a potential risk in this code. If you loop through the points to create a where clause with your Object ID, you assume that the values of the ObjectID is a range without gaps in its values. This might be the case, but if you edit the featureclass and delete a feature, it will no longer be the case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To create a more stable way you could use something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14075209603841950" jivemacro_uid="_14075209603841950"&gt;
&lt;P&gt;fc_pnts = "C:/Users/Ryan/Documents/arcgis_folder/sitetwoworkarea.gdb/route_one_points"&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# determine the ObjectID field name&lt;/P&gt;
&lt;P&gt;fld_oid = arcpy.Describe(fc_pnts).OIDFieldName&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# make a list of all the ObjectID's in the featureclass&lt;/P&gt;
&lt;P&gt;lst_oid = [row[0] for row in arcpy.da.SeachCursor(fc_pnts, ("OID@"))]&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;# loop through oid's and create the where clause&lt;/P&gt;
&lt;P&gt;for oid in lst_oid:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; where = "{0} = {1}".format(arcpy.AddFieldDelimiters(fc_pnts, fld_oid), oid)&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 Aug 2014 18:03:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/issue-with-copy-features-in-python/m-p/595070#M46614</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2014-08-08T18:03:00Z</dc:date>
    </item>
  </channel>
</rss>

