Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm looking getting familiar with using ArcPy scripting within ArcMap to automate some common requirements (buffering, etc), however have some queries on how this is all set up. I'm running Arc 10.2 for Desktop with Python 2.7 installed at C:\Python27\ArcGIS10.2 (I also have Py Ver 3 as well).

Can someone enlighten me in a few words on difference between, say, arcpy.analysis.Buffer and arcpy.Buffer_analysis and where the applicable scripts reside and how they work. I've found the analysis.py script at Program Files\ArcGIS\Desktop10.2\arcpy\arcpy\Geoprocessing which contains the Buffer class within the script and this would run. I assume this essentially sits behind the ArcToolbox\Analysis\Proximity\Buffer tool. However the Buffer_analysis also comes up as an option when I type but cannot find where this sits. I know sometimes different versions of the programs have changes.

I have had a look at a few answers on this site which discusses this general topic and some of the issues.

Thanks

share|improve this question
add comment

2 Answers 2

up vote 8 down vote accepted

You can call the GP tools in two ways:

arcpy.%toolbox%.%toolname%

or

arcpy.%toolname%_%toolbox%

Both are calling the same function, so there is no difference. It is a matter of taste; I always call functions in the arcpy.Buffer_analysis format because I seem to read the name tool faster in this way (I see first the toolname, and often seeing the toolbox is irrelevant).

I believe this naming convention was necessary to introduce because there are a couple of GP tools that have the same name, but are located in different toolboxes (classical example is Clip (Analysis) and Clip (Data Management).

Find the convention you like most and then stay consistent throughout your code by using just one naming format.

share|improve this answer
    
Thanks Alex, Yep looking in the script for Buffer I see Buffer_analysis mentioned. Arc's habit of having same names in different locations is a bit confusing at first. –  DirkB Jul 3 at 0:22
add comment

As you suspect arcpy.analysis.Buffer and arcpy.Buffer_analysis are two equivalent ways to run the same tool.

share|improve this answer
    
Thanks PolyGeo, just getting the hang of this. I assumed that it would be one rather than having two different ways to do the same thing; can be confusing when starting out. –  DirkB Jul 3 at 0:25
    
@DirkB No problem - the first time I saw arcpy.analysis.Buffer syntax used was in an answer by Blah238 and I tried to correct his "mistake". –  PolyGeo Jul 3 at 0:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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