3 New Features of the ArcGIS API for Python

by | Jan 22, 2018

Late December of 2017, Esri released the 1.3 version of their ArcGIS API for Python. The release counts many new features and capabilities. Three of these are covered below: easier login to ArcGIS Online, a new module for data enrichment and an easier ways to save and publish maps.

The new 1.3 version of the API is the follow-up of the 1.2.4 version, released in the summer of 2017. The latest version counts many different new features and incorporates many user requests that make the API easier to use. The API is extended through new modules and submodules, more support for ArcGIS Online content and geospatial file formats, among others. Here are some three new interesting features:

  1. Easier login to ArcGIS Online

Using the API to log in to ArcGIS Online has become easier as you can now use your login credentials to a public ArcGIS Online account. You can now use the same login info to get access to ArcGIS Online through a browser and the API. Using the API, you pass in the URL of ArcGIS Online, your username and password as follows:

import arcgis

from arcgis.gis import GIS

gis = GIS(“https://www.arcgis.com”, “username”, “password”)

This way of login makes more sense as the same password and username are used to login to ArcGIS Online using the web browser. Before the 1.3 version, using the API you could only use an anonymous login or a personalized one, such as an ArcGIS Developer Account, an organizational account for ArcGIS Online or a 21-day trial version account.

  1. A new module for data enrichment

The API now has a new module called the GeoEnrichment module that provides information about the people, places, and businesses in a specific area. The module provides access to a large collection of data sets including population, income, housing, consumer behavior, and the natural environment. These data sets can be queried and are returned as a pandas DataFrame. The pandas library is installed with the API, so there´s no need to do a separate install.

Another handy feature of the module is to define study areas, such as cities, counties or states. These areas have associated statistical information that can be used for doing spatial analysis and create reports, which are PDF files that combine tabular data with graphs and bars. This can all be done using Python and the API inside a Jupyter Notebook.

  1. Save and publish web maps directly from map widgets

A very powerful feature is the capability to save and publish web maps through your ArcGIS Online account directly from a map widget. If you have created a map through the API that you´d like to save and/or share by publishing it through your ArcGIS Online account, you can do this with a minimum amount of code, using the “save” method on the map widget that shows your newly created map, that will be stored next and published immediately through your ArcGIS Online account. To be able to do this, you need to have a personalized account and use it to login with the API to ArcGIS Online and have permission to publish content (in other words, this won´t work with an anonymous account).

Web maps form a separate class in the API’s mapping module and need to be imported first before you can use them inside your Python code. Then, you can define the web map´s properties such as title, snippet and tags and finally save the item. The item is published immediately and can be displayed by repeating the item´s variable name:

from arcgis.mapping import WebMap

wm = WebMap()

web_map_properties = {‘title’:’My Map ‘, ‘snippet’:’This map displays items about …”, ‘tags’:’ArcGIS Python API’}

web_map_item = wm.save(item_properties=web_map_properties)

web_map_item

Esri defines a web map as “an interactive display of geographic information through a composition of web layers, basemap and much more”. Web map items are 2D maps, stored as JSON files defining the bookmarks, layers, their symbology, order and other cartographic information. Web maps and scenes are stored on the user´s portal. They can be accessed and edited through the content pane when logging into ArcGIS Online.

Upcoming Classes – Introduction to the ArcGIS API for Python

March 27th and 28th in Portland

April 5th and 6th in Denver

Categories

Recent Posts

Eric van Rees
Eric van Rees is a freelance writer and editor. His specialty is GIS technology. He has more than eight years of proven expertise in editing, writing and interviewing as editor and editor-in-chief for the international geospatial publication GeoInformatics, as well as GIS Magazine and CAD Magazine, both published in Dutch. Currently, he writes about geospatial technology for various clients, publications and blogs.

Sign up for our weekly newsletter
to receive content like this in your email box.