Sunday, 10 September 2017

Terminology for distinguishing ArcPy installed with ArcGIS 10.x for Desktop from that which comes with ArcGIS Pro?


ArcGIS Pro uses Python 3 whereas the other ArcGIS for Desktop applications (ArcMap, ArcCatalog, ArcScene and ArcGlobe) use Python 2 and



the changes introduced with ArcGIS Pro were significant enough to merit a module name space change. The new name also offers more flexibility in terms of the capabilities arcpy.mp can offer. For example, in addition to map automation, arcpy.mp can also provide project level management.




Is there an Esri recommended way to refer to the ArcPy site-package that is imported into Python 3, that enables it to be distinguished during communication between ArcPy developers from the ArcPy site-package that is imported into Python 2?


It is clearly not identical (although it may be very similar) because when I run the script below on a machine that has both ArcGIS 10.3.1 and ArcGIS Pro 1.1.1 installed, from Python 2 vs Python 3, two different results occur.


import arcpy

if arcpy.Exists("C:/Temp/test.gdb"):
arcpy.Delete_management("C:/Temp/test.gdb")
arcpy.CreateFileGDB_management("C:/Temp", "test", "CURRENT")
arcpy.CreateFishnet_management("C:/Temp/test.gdb/TestFC",
"0 0","0 1","1","1","2", "2",
"","NO_LABELS","DEFAULT","POLYGON")

arcpy.MakeFeatureLayer_management("C:/Temp/test.gdb/TestFC","TestFC_Layer")
arcpy.MakeTableView_management("C:/Temp/test.gdb/TestFC","TestFC_View")
arcpy.CopyRows_management("TestFC_View","C:/Temp/test.gdb/TestTable")
arcpy.AddRelate_management("TestFC_Layer", "OID", "C:/Temp/test.gdb/TestTable", "OBJECTID", "test_relate")

If you put the above code into a Python script and run it using IDLE 2.7.8 the result is:


Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>


Traceback (most recent call last):
File "C:\Temp\test.py", line 12, in
arcpy.AddRelate_management("TestFC_Layer", "OID", "C:/Temp/test.gdb/TestTable", "OBJECTID", "test_relate")
AttributeError: 'module' object has no attribute 'AddRelate_management'
>>>

I expected this because ArcPy, when used with ArcGIS 10.x for Desktop from Python 2, does not have an Add Relate tool.


If you put the above code into a Python script and run it using IDLE 3.4.1 the result is:


Python 3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:45:13) [MSC v.1600 64 bit (AMD64)] on win32

Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
>>>

i.e. it worked!


I expected this too because ArcPy, when used with ArcGIS Pro from Python 3, does have an Add Relate tool.


When ArcGIS users are communicating between themselves about ArcPy since the release of ArcGIS Pro, there seems not to be a recommended way to describe the distinction.


Often it may be possible to tell from context, but in at least one question here (Add/Remove Relate using ArcPy without ArcGIS Pro?), which led to this one, the precise context within which the term ArcPy is being used was not initially clear, and which it was would lead to very different answers.


When working with ArcGIS, I always prefer to use the terminology that Esri uses, in order to be respectful to its developers, and I do the same for any development team.



Perhaps when you use/test ArcPy and want to communicate what you did with another ArcPy developer, like I have tried to in this question, then you just need to be careful to say:



  1. whether ArcGIS Pro and/or ArcMap etc is installed; and/or

  2. whether you are testing/using the script against Python 3 and/or Python 2


Much ArcPy code will run successfully without knowing the above (the first seven lines in my test above did), but as illustrated in the test code and procedure, some will not.


I think that I am going to have to say either:



  • for this test/tool/application I used ArcPy with Python 2 and the ArcGIS 10.x architecture; or

  • for this test/tool/application I used ArcPy with Python 3 and ArcGIS Pro



If Esri were using terminology like "ArcPy" and "ArcPy Pro" (as an example) then we would have a concise way to make the distinction but, from comments and an answers here, that path has not been taken.



Answer



The contribution that I think helps answer this the most is the comment by @khibma:



to my knowledge nothing on external Esri sites, nor internally do we call it anything other than arcpy. If in conversation it's unclear we add the product (10 or pro) name to the discussion.



To save having to write a sentence each time I am working with an aspect of ArcPy, in my day to day work, and I know or suspect it differs when in an ArcGIS Pro context, I will probably describe it as "ArcPy with ArcGIS Pro" or "ArcPy with Pro" (for short), and let people assume that I am talking about ArcPy with an ArcGIS 10.x architecture any time that I do not qualify it that way.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...