Part 1 - Introduction to using the map widget¶
Introduction to the
ArcGIS API for Python is easy to learn and extremely useful for data scientists, GIS administrators, and GIS analysts. One of the features that makes this API so powerful is its integration with
Jupyter Notebook. The interactive Jupyter Notebook environment is built around the concept of cells that can contain executable code or text and illustrative graphics written in Markdown format. Cells can be run in any order and any number of times. When a cell is run, its output is displayed immediately below the cell. This encourages tweaking and rerunning code until the perfect solution is found—illustrating the
REPL paradigm in action.
Because it is a web application running in a browser, Jupyter Notebook supports the display of graphic outputs. Write a snippet of Python code to plot a bar chart of household income of a county, and the chart will be displayed right below the cell containing that code.
Jupyter Notebook is also a great medium to work with and explore spatial data. Using just a single line of code, a live interactive map can be inserted into a notebook. Another line of code can add content to that map that is the result of a search. That content can be added with its default symbology or using smart mapping the API can figure out how best to symbolize the data.
Spatially Enabled DataFrame (SeDF) objects returned from a query for features in a feature layer can be visualized as a table in Jupyter Notebook.
Workflows, data connections, outputs in the form of illustrative charts and maps, informational text about conclusions — these can all be stored and worked with in a notebook. A Jupyter Notebook can become a functional record of a workflow that can be shared with anyone. All the recipient must do is run the cells to reproduce that workflow. Jupyter Notebook encourages research that is reproducible, since not only the findings, but the code used to arrive at them, are stored.
arcgis.widgets module offers components for managing maps and scenes to visualize GIS data and analysis in a rich, user-friendly, and interactive way that is specifically designed to work with 2D or 3D data content.
GIS object includes a map widget (of the
arcgis.widgets.MapView class) for displaying geographic locations, visualizing GIS content, and the results of your analysis. Based on
MapView class creates a mapping widget for Jupyter Notebook and JupyterLab.
To use the map widget, call
gis.map() and assign it to a variable that you can then query to bring up the widget in the notebook.
from arcgis.gis import GIS # Create a GIS object, as an anonymous user for this example gis = GIS()
# Create a map widget map1 = gis.map('Paris') # Passing a place name to the constructor # will initialize the extent of the map. map1