Is there any better documentation for the Python API?

117
4
03-29-2020 01:48 PM
Highlighted
Regular Contributor

Hi all

Is there any better documentation available for the ArcGIS Python API anywhere? Not sure if it's just me but I find the current "api reference" almost impossible to use.

API Reference for the ArcGIS API for Python — arcgis 1.8.0 documentation 

E.g. I want to get a layer object and use it. I click on the "Layer" link. It tells me how to get a layer, but nothing about the layer object I get. Are we supposed to jump across to some other unlinked documentation to find out what properties the layer object has? Or do we trawl through youtube videos of presentations or sample notebooks to piece together what to do?

Any help or better resources appreciated.

Cheers.

-Paul

4 Replies
Highlighted
New Contributor III

Yes. The documentation is not great. 

Your best option to learn this API is to debug heavily using a good IDE and browse the objects. For an even better understanding you should 'step in’ the debugger into the API the scripts themselves. 

Esri should really revamp efforts to improve documention on this API. Even the samples they provide are stale and old. 

Highlighted
Regular Contributor

Yeah that's pretty much what we're doing at the moment.

Given that I think the API is pretty popular already it would be great if there was better documentation!

Highlighted
MVP Esteemed Contributor
C:\........\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis

Having Notepad++ or similar text editor open can also be your friend since documentation within the scripts is sparse there and import and dependencies are often private methods.  After a while you find out that things eventually lead back to Pro toolbox calls, stuff in arcgisscripting or numpy/pandas.  For a lot of functionality, the Pro help files are applicable.

A handy tool if supported by your ide is to examine the code directly for whatever class/method you are interested in.

Here is an example using Spyder... line 1 the import ... line 3  the ?? marks to pull up the code for arcgis.gis.Layer

It just saves you navigating through the trail as to where the class is actually implemented.

import arcgis

arcgis.gis.Layer??

Init signature: arcgis.gis.Layer(url, gis=None)
Source:
class Layer(_GISResource):
"""
The layer is a primary concept for working with data in a GIS.

Users create, import, export, analyze, edit, and visualize layers.

Layers can be added to and visualized using maps. They act as inputs to and outputs from analysis tools.

Layers are created by publishing data to a GIS, and are exposed as a broader resource (Item) in the
GIS. Layer objects can be obtained through the layers attribute on layer Items in the GIS.
"""


def __init__(self, url, gis=None):
super(Layer, self).__init__(url, gis)
self.filter = None

............ huge snip ..........................
Reply
0 Kudos
Highlighted
Esri Contributor

The Using Feature Layers | ArcGIS for Developers  section in the guide has documentation on the properties and how to access them. As the API works against several versions of ArcGIS Enterprise and ArcGIS Online, the specific properties are not hard-coded but dynamic depending upon the capabilities of the backend GIS you are working against.