Python Script developed with Arc 10.2.1 breaks in 10.3

07-18-2016 01:37 PM
New Contributor II

I wrote a script the runs through a database and based on certain criteria deletes out data.  I run this to clear the way for new updated data that will be loaded.  It checks what the name starts with ("p*" or "a*"-- that type of thing) and it also checks the geometry type-- which is where it seems to be running into trouble.  The error crops up when it gets to the line features saying that shapetype "Polyline" or "Line" doesn't exist.  It still recognized shapetype "Point" and it hasn't even gotten to shapetype "Polygon" yet because it crashes before that.

When I query the shapetype via the python command window in arc it still says "Polyline" for the line files, so I don't understand where the problem is.

This script run perfectly in 10.2.1.

0 Kudos
4 Replies
Occasional Contributor II


When you refer to "based on certain criteria deletes out data", do you mean you delete the entire feature class or delete features within the feature class?  This of course would change how you access the data you are trying to delete.  For entire feature classes...

Shape types are:

  • Polygon
  • Polyline
  • Point
  • Multipoint
  • MultiPatch

From your tags, I would assume you are utilizing some form of arcpy.Describe?

Like this example:

import arcpy
arcpy.env.workspace = r'Database Connections\your database connection.sde'

feature_list = arcpy.ListFeatureClasses()

for feature in feature_list:
  desc = arcpy.Describe(feature)
   if desc.shapetype == 'Polyline':

Can you post a snippet of your code and the exact error message? That would be very helpful in investigating. I am wondering if there is some other operation that is interfering with your delete.



New Contributor II

for l in lList:

     L = format(l)

     LN = os.path.basename(L)

     lDesc = arcpy.Describe(L)

     if lDesc.shapetype == "Polyline':

          sel_1 = arcpy.SelectLayerbyLocation(L, "WITHIN", aoiNew, "", "New_Selection")

          cnt_1 = arcpy.GetCount_management(sel_1)

          if cnt_1 != 0:



               print ("No Features to delete")

That is it, more or less.  It deletes features within an aoi, not an entire feature class.

0 Kudos
Occasional Contributor II


If that is an exact snippet of your code, your quotes around Polyline do not match.  You have a " closed by a ' in:

if IDESC.shapetype == "Polyline':

This would certainly cause your issue failing on this type of feature.  However, your python IDE shouldn't even let you run this.  You would get a

SyntaxError: EOL while scanning string literal

Let me know if your code displays this same type of quote mismatch.  If not, I'll take a further look.


New Contributor II

That was just a typographical error when I was typing here.  The script it correct.

It suddenly started working now.  I think it may have been be having issues because the toolbox was reaching across a network for the script.  It seems to be fine now.

0 Kudos