[Tutor] Reprojection tool for vector datasets

Steven D'Aprano steve at pearwood.info
Tue Aug 9 13:06:32 CEST 2011


Helen Brown wrote:
> I am such a novice at this but I have gotten to a place where I am
> stuck. The attachment is what I have done so far but it also has an
> error for indentation. I will be working on that to. I have place
> comment as to what I want the modules to do but that is as far as I
> can go. Can someone lead me to the finish line ? I have four datasets
> and they are supposed to be reproject to NAD 1983 UTM Zone 10. Plus I
> can not have any hard code.

I don't understand what you mean by "I can not have any hard code".


The first thing I would do is get rid of the try...except clause. You 
have this:

try:
     [lots and lots of indented code]
except:
      # Report an error messages
     arcpy.AddMessage("This project is incomplete")
     #Report any error messages that the projection might have generated
     arcpy.AddMessage(arcpy.GetMessages())



This is a bad design, because it hides genuine programming bugs and 
changes them to say "This project is incomplete". How useless is that? 
If your code has a bug, you need to see what the bug is before you can 
fix it. So I recommend you do this:


  (1) Take all the lines between "try" and "except" and outdent them 
back to the margin.

(2) Delete the line "try".

(3) Delete the line "except".

(4) Comment out the four lines following "except"

     ## Report an error messages
     #arcpy.AddMessage("This project is incomplete")
     ##Report any error messages that the projection might have generated
     #arcpy.AddMessage(arcpy.GetMessages())

(rather than delete them, because you may have to add them back in later).


Now run the code and see what errors you get, if any, and fix them. 
You'll almost certainly get lots of errors, but only one at a time, 
fortunately! Read the error messages, try to understand what they are 
telling you, and try to fix them.

And don't be shy about coming back for assistance.




-- 
Steven



More information about the Tutor mailing list