For using ArcGIS API for Python, credentials have to be provided gis = GIS("http://www.arcgis.com", "username", "password")
.
from arcgis.gis import GIS
gis = GIS("http://www.arcgis.com", "***", "***")
help(gis)
Information from help(gis)
class GIS(builtins.object)
| GIS(url=None, username=None, password=None, key_file=None, cert_file=None, verify_cert=True, set_active=True, client_id=None, profile=None, **kwargs)
|
| .. _gis:
|
| A GIS is representative of a single ArcGIS Online organization or an ArcGIS Enterprise deployment. The GIS object
| provides helper objects to manage (search, create, retrieve) GIS resources such as content, users, and groups.
|
| Additionally, the GIS object has properties to query its state, which is accessible using the properties attribute.
|
| The GIS provides a mapping widget that can be used in the Jupyter Notebook environment for visualizing GIS content
| as well as the results of your analysis. To create a new map, call the map() method.
|
| The constructor constructs a GIS object given a url and user credentials to ArcGIS Online
| or an ArcGIS Enterprise Portal. User credentials can be passed in using username/password
| pair, or key_file/cert_file pair (in case of PKI). Supports built-in users, LDAP, PKI, Integrated Windows Authentication
| (using NTLM and Kerberos) and Anonymous access.
|
| If no url is provided, ArcGIS Online is used. If username/password
| or key/cert files are not provided, the currently logged-in user's credentials (IWA) or anonymous access is used.
|
| Persisted profiles for the GIS can be created by giving the GIS authorization credentials and
| specifying a profile name. The profile stores all of the authorization credentials (except the password) in the
| user's home directory in an unencrypted config file named .arcgisprofile. The profile securely stores the password
| in an O.S. specific password manager through the `keyring <https://pypi.python.org/pypi/keyring>`_ python module.
| (Note: Linux systems may need additional software installed and configured for proper security) Once a profile has
| been saved, passing the profile parameter by itself uses the authorization credentials saved in the configuration
| file/password manager by that profile name. Multiple profiles can be created and used in parallel.
|
| See https://developers.arcgis.com/python/guide/working-with-different-authentication-schemes/ for examples.
|
|
| ================ ===============================================================
| **Argument** **Description**
| ---------------- ---------------------------------------------------------------
| url Optional string. If URL is None, then the URL will be ArcGIS
| Online. This should be a web address to either a local Portal
| or to ArcGIS Online in the form:
| <scheme>://<fully_qualified_domain_name>/<web_adaptor> (Portal Example)
| https://gis.example.com/portal
| ---------------- ---------------------------------------------------------------
| username Optional string. The login user name (case-sensitive).
| ---------------- ---------------------------------------------------------------
| password Optional string. If a username is provided, a password is
| expected. This is case-sensitive. If the password is not
| provided, the user is prompted in the interactive dialog.
| ---------------- ---------------------------------------------------------------
| key_file Optional string. The file path to a user's key certificate for PKI
| authentication
| ---------------- ---------------------------------------------------------------
| cert_file Optional string. The file path to a user's certificate file for PKI
| authentication. If a PFX or P12 certificate is used, a password is required.
| If a PEM file is used, the key_file is required.
| ---------------- ---------------------------------------------------------------
| verify_cert Optional boolean. If a site has an invalid SSL certificate or is
| being accessed via the IP or hostname instead of the name on the
| certificate, set this value to False. This will ensure that all
| SSL certificate issues are ignored.
| The default is True.
| **Warning** Setting the value to False can be a security risk.
| ---------------- ---------------------------------------------------------------
| set_active Optional boolean. The default is True. If True, the GIS object
| will be used as the default GIS object throughout the whole
| scripting session.
| ---------------- ---------------------------------------------------------------
| client_id Optional string. Used for OAuth authentication. This is the
| client ID value.
| ---------------- ---------------------------------------------------------------
| profile Optional string. the name of the profile that the user wishes to use
| to authenticate, if set, the identified profile will be used to login
| to the specified GIS.
| ================ ===============================================================
|
| In addition to explicitly named parameters, the GIS object supports optional key word
| arguments:
|
| ================ ===============================================================
| **kwargs** **Description**
| ---------------- ---------------------------------------------------------------
| proxy_host Optional string. The host name of the proxy server used to allow HTTP/S
| access in the network where the script is run.
|
| ex: 127.0.0.1
| ---------------- ---------------------------------------------------------------
| proxy_port Optional integer. The proxy host port. The default is 80.
| ---------------- ---------------------------------------------------------------
| token Optional string. This is the Enterprise token for built-in
| logins. This parameter is only honored if the username/password
| is None and the security for the site uses BUILT-IN security.
| ================ ===============================================================
|
|
|
|
| .. code-block:: python
|
| # Usage Example 1: Anonymous Login to ArcGIS Online
|
| gis = GIS()
|
| .. code-block:: python
|
| # Usage Example 2: Built-in Login to ArcGIS Online
|
| gis = GIS(username="someuser", password="secret1234")
|
| .. code-block:: python
|
| # Usage Example 3: Built-in Login to ArcGIS Enterprise
|
| gis = GIS(url="http://pythonplayground.esri.com/portal",
| username="user1", password="password1")
|
| .. code-block:: python
|
| # Usage Example 4: Built-in Login to ArcGIS Enterprise, ignoring SSL errors
|
| gis = GIS(url="http://pythonplayground.esri.com/portal", username="user1",
| password="password1", verify_cert=False)
|
| .. code-block:: python
|
| # Usage Example 5: Anonymous ArcGIS Online Login with Proxy
|
| gis = GIS(proxy_host='127.0.0.1', proxy_port=8888)
|
| .. code-block:: python
|
| # Usage Example 6: PKI Login to ArcGIS Enterprise, using PKCS12 user certificate
|
| gis = GIS(url="https://pkienterprise.esri.com/portal",
| cert_file="C:\users\someuser\mycert.pfx", password="password1")
|
| Methods defined here:
|
| __init__(self, url=None, username=None, password=None, key_file=None, cert_file=None, verify_cert=True, set_active=True, client_id=None, profile=None, **kwargs)
| Constructs a GIS object given a url and user credentials to ArcGIS Online
| or an ArcGIS Portal. User credentials can be passed in using username/password
| pair, or key_file/cert_file pair (in case of PKI). Supports built-in users, LDAP,
| PKI, Integrated Windows Authentication (using NTLM and Kerberos) and Anonymous access.
|
| If no url is provided, ArcGIS Online is used. If username/password
| or key/cert files are not provided, logged in user credentials (IWA) or anonymous access is used.
|
| Persisted profiles for the GIS can be created by giving the GIS authorization credentials and
| specifying a profile name. The profile stores all of the authorization credentials (except the password) in the
| user's home directory in an unencrypted config file named .arcgisprofile. The profile securely stores the password
| in an O.S. specific password manager through the `keyring <https://pypi.python.org/pypi/keyring>`_ python module.
| (Note: Linux systems may need additional software installed and configured for proper security) Once a profile has
| been saved, passing the profile parameter by itself uses the authorization credentials saved in the configuration
| file/password manager by that profile name. Multiple profiles can be created and used in parallel.
|
| If the GIS uses a secure (https) url, certificate verification is performed. If you are using self signed certificates
| in a testing environment and wish to disable certificate verification, you may specify verify_cert=False to disable
| certificate verification in the Python process. However, this should not be done in production environments and is
| strongly discouraged.
|
| __repr__(self)
| Return repr(self).
|
| __str__(self)
| Return str(self).
|
| map(self, location=None, zoomlevel=None, mode='2D', geocoder=None)
| Creates a map widget centered at the declared location with the specified
| zoom level. If an address is provided, it is geocoded
| using the GIS's configured geocoders and if a match is found, the geographic
| extent of the matched address is used as the map extent. If a zoomlevel is also
| provided, the map is centered at the matched address instead and the map is zoomed
| to the specified zoomlevel. See :class:`~arcgis.widgets` for more information.
|
| Note: The map widget is only supported within Jupyter Notebook.
|
| ================== ====================================================================
| **Argument** **Description**
| ------------------ --------------------------------------------------------------------
| location Optional string. The address or lat-long tuple of where the map is to be centered.
| ------------------ --------------------------------------------------------------------
| zoomlevel Optional integer. The desired zoom level.
| ------------------ --------------------------------------------------------------------
| mode Optional string of either '2D' or '3D' to specify map mode. Defaults to '2D'.
| ------------------ --------------------------------------------------------------------
| geocoder Optional Geocoder. Allows users to specify a geocoder to find a given location.
| ================== ====================================================================
|
|
| :return:
| The map widget (displayed in Jupyter Notebook when queried).
|
| update_properties(self, properties_dict)
| Updates the GIS's properties from those in properties_dict. This method can be useful
| for updating the utility services used by the GIS.
|
|
| =============== ====================================================================
| **Argument** **Description**
| --------------- --------------------------------------------------------------------
| properties_dict Required dictionary. A dictionary of just those properties and
| values that are to be updated.
| =============== ====================================================================
|
| :return:
| True if successfully updated, False if unsuccessful.
|
|
| .. note::
| For examples of the property names and key/values to use when updating utility services,
| refer to the Portal parameters section at https://developers.arcgis.com/rest/users-groups-and-items/common-parameters.htm
|
| .. code-block:: python
|
| # Usage Example: Update the geocode service
|
| gis = GIS(profile='xyz')
| upd = {'geocodeService': [{
| "singleLineFieldName": "Single Line Input",
| "name": "AtlantaLocator",
| "url": "https://some.server.com/server/rest/services/GeoAnalytics/AtlantaLocator/GeocodeServer",
| "itemId": "abc6e1fc691542938917893c8944606d",
| "placeholder": "",
| "placefinding": "true",
| "batch": "true",
| "zoomScale": 10000}]}
|
| gis.update_properties(upd)
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| content
| The resource manager for GIS content. See :class:`~arcgis.gis.ContentManager`.
|
| datastore
|
| groups
| The resource manager for GIS groups. See :class:`~arcgis.gis.GroupManager`.
|
| hub
| The resource manager for GIS hub. See :class:`~arcgis.apps.hub.Hub`.
|
| org_settings
| The portal settings resource is used to return a view of the
| portal's configuration as seen by the current users, either
| anonymous or logged in. Information returned by this resource
| includes helper services, allowed redirect URIs, and the current
| configuration for any access notices or information banners.
|
| ====================== ===============================================================
| **Parameters** **Description**
| ---------------------- ---------------------------------------------------------------
| settings Required Dict. A dictionary of the settings
|
| ========================== =============================================
| **Fields** **Description**
| -------------------------- ---------------------------------------------
| anonymousAccessNotice Dict. A JSON object representing a notice that is shown to your organization's anonymous users.
| Ex: {'title': 'Anonymous Access Notice Title', 'text': 'Anonymous Access Notice Text', 'buttons': 'acceptAndDecline', 'enabled': True}
| -------------------------- ---------------------------------------------
| authenticatedAccessNotice Dict. A JSON object representing a notice that is shown to your organization's authenticated users.
| Ex: {'title': 'Authenticated Access Notice Title', 'text': 'Authenticated Access Notice Text', 'buttons': 'okOnly', 'enabled': True}
| -------------------------- ---------------------------------------------
| informationalBanner Dict. A JSON object representing the informational banner that is shown at the top of your organization's page.
| Ex: {'text': 'Header Text', 'bgColor': 'grey', 'fontColor': 'blue', 'enabled': True}
| -------------------------- ---------------------------------------------
| clearEmptyFields Bool. If True, any empty dictionary will be set to null.
| ========================== =============================================
|
| ====================== ===============================================================
|
| :returns: Dictionary
|
| properties
| The properties of the GIS.
|
| url
| Readonly URL of the GIS you are connected to.
|
| users
| The resource manager for GIS users. See :class:`~arcgis.gis.UserManager`.
|
| version
| returns the GIS version number
References: