Enriching GIS data with thematic information

Mapping and visualization

The GIS object in the gis module is the most important object when working with the ArcGIS API for Python. The GIS object represents the GIS you are working with, be it ArcGIS Online or an instance of ArcGIS Enterprise. You use the GIS object to consume and publish GIS content and administrators may use it to manage GIS users, groups and datastores. This object becomes your entry point in your Python script when using the API.

To use the GIS object, import GIS from the arcgis.gis module:

In [1]:

fromarcgis.gisimportGIS

To create the GIS object, we pass in the url and our login credentials as shown below:

In [2]:

gis=GIS("https://www.arcgis.com","arcgis_python","P@ssword123")

If connecting to an ArcGIS Enterprise in your premises, your URL becomes http://machinename.domain.com/webadapter. Your GIS can support a number of authentication schemes, refer to this section of the guide to know how to authenticate your scripts and notebooks for various such schemes.

Below, we're connecting to ArcGIS Online (the default GIS used when the url is not provided) as an anonymous user:

In [2]:

gis=GIS()

Adding a '?' mark after an object and querying it brings up help for that object in the notebook:

In [3]:

gis?

The notebook provides intellisense and code-completion. Typing a dot after an object and hitting tab brings up a drop-down with its properties and methods:

The GIS object provides helper objects to manage the GIS resources, i.e. the users, groups, content and datastores. These helper utilities are in the form of helper objects named: users, groups, content and datastore respectively. The helper utility for managing user roles named roles is available as a property on the helper object users.

Each such helper object has similar patterns of usage: there are methods to get(), search() and create() the respective resources.

The prescribed programming pattern is to not create the GIS resources (user, group, item, role, datastore) directly using their constructor, but to access them through their corresponding helper objects described above.

Thus, to access a user, you would use the users property of your gis object which gives you an instance of UserManager class. You would then call the get() method of the UserManager object and pass the user name of the user you are interested in.

The GIS object includes a map widget that can be used to visualize the content of your GIS as well as see the results of your analysis. Let's bring up a map of Palm Springs, CA:

In [8]:

map1=gis.map("Palm Springs, CA")map1

We can search for content in our GIS. Let's search for Hiking Trails in the Palm Springs region. We do that by calling gis.content.search() and for each web map or web layers that gets returned, we can display its rich representation within the notebook:

Palm Springs TrailsTrails in the Palm Springs area affected by the BLM - Agua Caliente land exchangeFeature Service by paniello_geodesign
Last Modified: March 13, 2015
0 comments, 96 views

Loop7Victor_WFLTrail going from Palm Canyon and back up VictorFeature Service by kgrahamACBCI
Last Modified: September 28, 2016
0 comments, 90 views

Albert E. Davies Wetland Trail at Lake Newport. Mill Creek Park, Boardman, OHLake Newport and the wetland at its southern end are both man-made, dating from the 1920s. Together they cover about 100 acres and in summer attract recreational kayakers, picnickers, and others. It’s rarely crowded, however, and from September to April, it can sometimes be completely deserted. The trail itself is only a few hundred meters long. Winding through reed-beds it dead-ends at a lookout on the lake facing an array of small islands, some of which are accessible only by kayak. The viewing platform is located at 41°03’09.76”N and 80°40’34.05”W. Parking is available a few hundred yards from the trail head; toilets are also provided. Access to the parking lot is from West Newport Drive in Mill Creek Park.
The wetlands are a good all-round bird-watching spot. A wide variety of warblers can be encountered during Spring and Fall migration. I’ve seen Palm, Yellow-Rumped, Black-Throated Green, and many others. On the east side of the viewing platform, across a few tens of meters of water, there is a mud-flat. Depending on the water level it varies considerably in size, occasionally disappearing altogether. Although small, it’s often a good place to look for wading birds, particularly in late summer and early fall. Among the ubiquitous Killdeer and Canada Geese, I have seen Least, Spotted, and Solitary Sandpipers and Lesser Yellowlegs on several occasions. Bald Eagles often can be spotted in the trees just across the water.
Visit year-round
This is my favorite "home patch." It's located between my home in Boardman and YSU, where I teach, so this is the place I bird most often – by far! During the academic year I usually stop in for twenty or thirty minutes early in the morning on the way to work at least every other day. By now I know pretty much every tree, bush, and mud-patch!
Web Map by bradshellito
Last Modified: August 11, 2016
0 comments, 84 views

Loop2WestFork_WFLA loop trail in Indian Canyons starting at the Trading Post parking lot and head down Palm Canyon to West Fork, to West Fork North, up Coffman to Murray Canyon, back down Coffman to Alexander and ending up back at the Trading Post.Feature Service by kgrahamACBCI
Last Modified: September 28, 2016
0 comments, 70 views

Albert E. Davies Wetland Trail at Lake Newport. Mill Creek Park, Boardman, OHLake Newport and the wetland at its southern end are both man-made, dating from the 1920s. Together they cover about 100 acres and in summer attract recreational kayakers, picnickers, and others. It’s rarely crowded, however, and from September to April, it can sometimes be completely deserted. The trail itself is only a few hundred meters long. Winding through reed-beds it dead-ends at a lookout on the lake facing an array of small islands, some of which are accessible only by kayak. The viewing platform is located at 41°03’09.76”N and 80°40’34.05”W. Parking is available a few hundred yards from the trail head; toilets are also provided. Access to the parking lot is from West Newport Drive in Mill Creek Park.
The wetlands are a good all-round bird-watching spot. A wide variety of warblers can be encountered during Spring and Fall migration. I’ve seen Palm, Yellow-Rumped, Black-Throated Green, and many others. On the east side of the viewing platform, across a few tens of meters of water, there is a mud-flat. Depending on the water level it varies considerably in size, occasionally disappearing altogether. Although small, it’s often a good place to look for wading birds, particularly in late summer and early fall. Among the ubiquitous Killdeer and Canada Geese, I have seen Least, Spotted, and Solitary Sandpipers and Lesser Yellowlegs on several occasions. Bald Eagles often can be spotted in the trees just across the water.
Visit year-round
This is my favorite "home patch." It's located between my home in Boardman and YSU, where I teach, so this is the place I bird most often – by far! During the academic year I usually stop in for twenty or thirty minutes early in the morning on the way to work at least every other day. By now I know pretty much every tree, bush, and mud-patch!
Web Mapping Application by bradshellito
Last Modified: August 11, 2016
0 comments, 62 views

We can then add the returned web layers to our map. To add the last layer returned above, we call the add_layer() method and pass in the layer for Palm Springs Trail:

In [10]:

# Let us filter out the item with title 'Trails' that we want to additem_to_add=[temp_itemfortemp_iteminitemsiftemp_item.title=="Trails"]map1.add_layer(item_to_add[0])

The above cell updated the map widget, if you scroll to the top, you can notice a new trail layer being rendered on the map.