See the README for installation requirements and instructions.
The ArcGIS API for Python follows a pythonic modular design. Whether talking of ArcGIS Online or ArcGIS Enterprise on-premise or in the cloud, your GIS is represented with the argis.gis module. The GIS class provides the information model from which you access all the tools to visualize, analyze, manage, and administer your GIS.
Below we'll log into ArcGIS Online anonymously and access the module's map widget to investigate the default behavior. Run the cell to bring up the default map.
Click the Open the Command Palette button on the Jupyter Notebook toolbar for instuctions on how to run a cell on the Operating System you use.
Set the map to a variable for access later in the notebook.
In [ ]:
from arcgis.gis import GIS
my_gis = GIS()
map = my_gis.map()
map
In [ ]:
print("Anonymous ArcGIS Online login:")
print("{:-<50}".format(''))
print("\tDefault Basemap: {}".format(map.basemap))
print("\tMap Center: {}".format(map.center))
print("\tMap Zoom Level: {}".format(map.zoom))
Enter in the url to your own portal, your own ArcGIS Online Organization, or to https://www.arcgis.com to access your Map Viewer. An example is included to show formatting.
Use the getpass module to hide the password for your portal. You'll be prompted to enter your password after running the cell. Hit enter when completed typing password.
In [ ]:
import getpass
password = getpass.getpass("Enter password: ")
#p_gis = GIS(<YOUR PORTAL HOME URL>, <USERNAME>, password, verify_cert=False)
#set verify_cert to False if ssl errors are returned regarding security
p_gis = GIS("https://hadrian.esri.com/portal/home", "admin", password, verify_cert=False)
# Entering a specific location and Zoom Level controls how the map draws
p_map = p_gis.map("Cannon Beach, OR", 12)
print("Successfully logged in as: " + p_gis.properties.user.username)
p_map
In [ ]:
print("ArcGIS Portal Instance login:")
print("{:-<50}".format(''))
print("\tDefault Basemap: {}".format(p_map.basemap))
print("\tMap Center: {}".format(p_map.center))
print("\tMap Zoom Level: {}".format(p_map.zoom))
In [ ]:
p_map.zoom = 15
p_map.height = '175px'
p_map.center = [45.889332, -123.960452] # center needs to be a list of longitude, latitude coordinates
To inspect the output, open the Step 1 - loading the gis map widget.html in your browser.
NOTE: Maps do not show in the html output. You'll have to download the repo and run the notebooks to produce that output.