2

I've been working on a project. A small part of it is to clip point features by ellipse polygons.

I need to loop through a set of IDs, when I call "clip" function via arcpy, a very strange error persists:

"ERROR 000732: Clip Features: Dataset Ellipse/ellipse_6406685702.0 does not exist or is not supported Failed to execute (Clip)"

the clip function worked fine if only a single ID was used, the error only occurs when it loops through the IDs.

I've checked Esri's help, and tried to appy some fixes, but none of them worked. I'm pretty sure the files such as ellipse_6406685702.0 indeed exist as I can use them one by one, but cannot use them in the batch way. This is the very last step of my project so I really need to get out of it.

Here is the code:

import arcpy
arcpy.env.workspace= "C:/Users/Ran/Desktop/TucsonTravelAnalysis/data/TucsonTravel.gdb"
fc = "All_Locations/Tucson_ppl"
pplWH= []
cursor = arcpy.da.SearchCursor(fc,["ID_individ","TripType"])
for row in cursor:
        if row[1]== 2:
            pplWH.append(row[0])
pplWH= list(set(pplWH))
for ID in pplWH:
 infc = "All_Locations/All_ND_points"
 clipfc= "Ellipse/ellipse_{0}".format(ID)
 outclipfc= "All_Locations/HW_NDpoints_{0}".format(ID)
 arcpy.Clip_analysis(infc, clipfc, outclipfc)
  • Have you tried with raw string flag as ---arcpy.env.workspace= r"C:/Users/Ran/Desktop/TucsonTravelAnalysis/data/TucsonTravel.gdb" – SIslam Jul 13 '15 at 8:22
  • Yes, I tried, I also tried double back slashes instead of "/" but none of them ever worked. – Ran Jul 13 '15 at 8:27
  • As ur error says Ellipse/ellipse_6406685702.0 is it a shapefile or featureclass-if featureclass "." is not allowed in featureclass name.Better you tell folder structure and type(shp or fc) of features you are working with. – SIslam Jul 13 '15 at 8:39
0

The format of your ID_individ field is probably "double" and that's how it is read. Turn it into an integer either when appending it to your pplWH list:

for row in cursor:
        if row[1]== 2:
            pplWH.append(int(row[0]))

or when creating the clipfc and outclipfc variables:

clipfc= "Ellipse/ellipse_{0}".format(int(ID))
outclipfc= "All_Locations/HW_NDpoints_{0}".format(int(ID))
  • Do you mean that there is no implicit type conversion-then why not str(ID)? – SIslam Jul 13 '15 at 9:18
  • @Slslam - No, there's no implicit type conversion, and turning it to a string won't remove the decimal, try for example a = 1.0 - print str(a). – GISGe Jul 13 '15 at 9:30
  • -But the OP's excerpt "I'm pretty sure the files such as ellipse_6406685702.0 indeed exist as I can use them one by one"- suggests that decimals need to be exist. – SIslam Jul 13 '15 at 9:34
  • @Slslam You can't use a point in the name of feature classes and feature datasets inside a gdb. – GISGe Jul 13 '15 at 9:44
  • It may be possible "Ellipse" is a folder and "ellipse_6406685702.0" is a shapefile inside that which permits "." in name- it may happen untill OP tells us the folder&/or GDB structure-Is not it better to wait, i just proposing. – SIslam Jul 13 '15 at 9:54
0

Thank you for the help, the problem was solved.

The solution is to change format(ID) into format(str(long(ID))).

".0" was not recognized so the error occurred.

I'm sorry for the assertion that "llipse_6406685702.0 indeed exist ", it turns out that I was mistaken, a feature class does not support .0 in arcpy . Specail Thanks to Slslam !

Hope my case can help others.

This is my first post in this forum and I've found people here are being very nice and helpul. I'd participate more in this community !

  • the format() function will convert the argument into a string, so it is not necessary to use str() within format(). – GISGe Jul 14 '15 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.