Select to view content in your preferred language

Arcpy Bug? loop error ..runs great for 899 iterations and then fails at the 900th

1568
9
Jump to solution
03-01-2012 06:19 AM
EricScharnhorst
Emerging Contributor
Before it breaks, my script does this in a loop:

for i in range (1, 2000):

if ID = i:

step 1: export one point whose ID = i, feature class to feature class
step 2: make polygon, 500 meter buffer around the point
step 3: clip a raster with the polygon from step 2
step 4: do a bunch of spatial analysis on the clipped raster
step 5: export a table with stats from step 4

The loop breaks at step 2 after the 900th iteration, which is just about 1/2 way to completion.

Here is the error message:
'File "C:\Programmer\ArcGIS\Desktop10.0\arcpy\arcpy\management.py", line 7692, in Clip
   raise e
arcgisscripting.ExecuteError: ERROR 000622: Failed to execute (Clip). Parameters are not valid.
ERROR 000628: Cannot set input into parameter rectangle.

The errors makes sense only because step 2 does not produce a polygon after the 900th time through the loop. Question is, why no polygon?

Thanks,
Eric
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
ChrisMathers
Deactivated User
That sounds like an error in your source point file then. Have you tried Repair Geometry on the point file?

Also, if you are using a cursor to iterate over a point file and exporting the points one at a time to a new feature class just for the geometry you can chop that step out by using the geometry object. The row object can give your the geometry to use as the input for the buffer tool. This would save the time it takes to write out to a new file over and over again.

View solution in original post

0 Kudos
9 Replies
ChrisMathers
Deactivated User
If the buffer isnt making a poly, what are the values for that record that are being put into the buffer?
0 Kudos
ChrisSnyder
Honored Contributor
What is your memory consumption upon the 899th loop? Perhaps you are running out of memory.
0 Kudos
EricScharnhorst
Emerging Contributor
If the buffer isnt making a poly, what are the values for that record that are being put into the buffer?


Values are good ..that record, and those that follow it all work when using the buffer tool by hand in ArcMap.
0 Kudos
EricScharnhorst
Emerging Contributor
What is your memory consumption upon the 899th loop? Perhaps you are running out of memory.


Memory is good. The loop breaks at 900 even if I start at 899, for example .."for i in range (899, 2000):"
0 Kudos
ChrisMathers
Deactivated User
Does it fail if you start at 900? How about 901? I run cursors on 117000 record parcel feature classes every Monday morning with no problem. Can we see the whole of the code?
0 Kudos
EricScharnhorst
Emerging Contributor
Does it fail if you start at 900? How about 901? I run cursors on 117000 record parcel feature classes every Monday morning with no problem. Can we see the whole of the code?


Yes, it fails also when starting at 900 or after 900.
0 Kudos
ChrisMathers
Deactivated User
That sounds like an error in your source point file then. Have you tried Repair Geometry on the point file?

Also, if you are using a cursor to iterate over a point file and exporting the points one at a time to a new feature class just for the geometry you can chop that step out by using the geometry object. The row object can give your the geometry to use as the input for the buffer tool. This would save the time it takes to write out to a new file over and over again.
0 Kudos
EricScharnhorst
Emerging Contributor
That sounds like an error in your source point file then. Have you tried Repair Geometry on the point file?

Also, if you are using a cursor to iterate over a point file and exporting the points one at a time to a new feature class just for the geometry you can chop that step out by using the geometry object. The row object can give your the geometry to use as the input for the buffer tool. This would save the time it takes to write out to a new file over and over again.


Bad news is Repair Geometry didn't change anything

Good news is the geometry object is working as advertised. Thanks for the tip, Chris. The loop is continuing now past 900, and each record is processed faster ..by about 2 seconds. This move will save the loop 1 hour in total.
0 Kudos
ChrisMathers
Deactivated User
Your welcome. Happy to help.
0 Kudos