Getting Started

The ArcGIS API for Python is a powerful Python package that can be used to manage, control and explore spatial data. It combines the best of data science with the power to manage your GIS infrastructure. The package is lightweight and nimble and allows users from all levels of GIS backgrounds to quickly map information, manage GIS infrastructure (servers, portals, etc.) and start understanding quickly.

Accessing the Package

I am going to assume the packagae has been installed. If you need help doing that step, please refer to https://developers.arcgis.com/python/guide/install-and-set-up/

In Python, librraries are loaded/accessed using the import statement as such:

In [1]:
import arcgis

Python also allows developers to access a part or parts of a library to let users only load what they need. This is done using the from < x > import < y >

In [2]:
from arcgis.gis import GIS

Here we just loaded the GIS class from the arcgis.gis module.

Now that we have what we need to login to our GIS, we can login or access a site anonymously.

The first example is showing how to login to Portal for ArcGIS (this code won't work unless you replace the values):

In [ ]:
gis = GIS(url="http://mysite.com/portal", username="useraccount", password="secret")

To access ArcGIS Online, you do not have to provide a url because it it the default site. Here you can specify the username and password for a non-anonymous connection, else you can just provide credentials to login to your organization.

In [3]:
gis = GIS()
In [ ]:
gis = GIS(username='myaccount', password='fake password')

Conclusion

This was a gentle introduction to accessing your site. For further information you can check out https://developers.arcgis.com/pthon for helpful user guides and examples.