Python scripts that run inside ArcMap vs ones that run outside?
How you get your inputs depends 100% on who the end user will be, but you're right, you won't be able to use raw_input in ArcMap at all. If you are going to be the only one using the script, there's nothing wrong with getting your inputs through raw_input, or hard coding paths as variables into your script. However, if anyone else will be using the script that may or may not have any scripting experience, it is best to use getParameterAsText() and implement your script as a script tool in ArcMap. Creating a script tool will give the user an interface that is similar to the one used by most ESRI tools (such as standard tools like buffer, etc...).
One thing to point out is that the way you have your raw_inputs designed creates a step by step interaction between the user and the script. If this is run using getParameterAsText() in ArcMap, the step by step will go away, and it will just be a series of settings that are input prior to running the script.
One of the main purposes for scripting is automation. If you are going to be running this on multiple datasets, you should check out loops. If you've come this far, you've probably read about them at least, but as an example for how you could use them: say you have multiple datasets that you need to perform the same operation on. You can write the code for the processes that need to be accomplished once, then include a 'for' loop that takes a list of datasets and performs the operation on each of them.
For things like spatial reference, you can 'steal' a spatial reference from an existing shapefile using arcpy.Describe() , or you can get a spatial reference input using getParameterAsText() (as long as you define the parameter as a spatial reference input when setting up the script tool). Using raw_input to get path names is a bit cumbersome.
In addition to @egdetti's great suggestions, you can greatly simplify your script by making some assumptions instead of writing if/else logic for every little condition.
For example:
Instead of checking whether each item exists beforehand, just assume it does and overwrite it by setting
arcpy.env.overwriteOutput = True
. Now you may have some reason why you need to check beforehand but more often than not overwriting is fine.Instead of checking whether the spatial reference option was set, and calling the same command two different ways, just pass the spatial reference variable to the command once and let it handle null or empty strings (which it will just fine).
Use
os.path.join
to join file path elements instead of using string concatenation, which is fraught with perils.E.g. instead of:
FGBpath = clientpath + "/" + client + ".gdb"
Use:
FGBpath = os.path.join(clientpath, client + ".gdb")