What's New in 2.4.0

Summary

The 2.4 Release contains many new changes that improve the performance and experience of using the Python API. The Python API incorporates the Jupyter Lab 4.0 and Notebook 7.0 architecture to align with how these applications process Python code. The backend architecture changes necessitated a complete overhaul of fundamental structures within the Python API which required both the removal of some modules & classes and the transfer of functionality into new modules, classes, and accompanying properties/methods.

These modifications change how some familiar functionality is accessed, and provides some new ways to work with your Web GIS organization. Let's take a look at some of these new updates.

Primary Python Support is for version 3.11. Secondary support is provided for Python 3.10 and 3.12. We have dropped Support for Python 3.9.

Refactor: arcgis.mapping module

The previous arcgis.mapping module functionality was documented in the following subsections in the Python API reference. The mapping module has been refactored into two new modules, the map and layers modules. Let's do a quick rundown of how those classes have been refactored.

Working with 2D Maps: Classes for working with Web Map items and packaging offline map areas

Working with 3D Maps: Classes for working the Web Scenes and the data types displayed through scene layers

Working with Map Service Layers: Classes for working with Map Services and the associated layers within them

The classes have been refactored into the arcgis.layers module documented under the Working with Map Service Layers subsection.

Working with OGC layers: Classes for working with services compliant with OGC standards

The arcgis.mapping.ogc submodule classes have all been refactored into the arcgis.layers module documented in the Working with OGC layers subsection.

Working with Map Forms: Components to control behavior for data collecting and editing in applications like Map Viewer or ArcGIS Field Maps

The functionality of the arcgis.mapping.forms submodule has been refactored into the arcgis.map module and accessed using the form() method of the MapContent class. Full reference documentation is provided in Forms reference documentation.

Utility Functions for Mapping: Class and functions for working with symbology and rendering in the map widget.

The WebMap class

The WebMap class has been deprecated and its functionality has been refactored into the Map class in the new arcgis.map module. Initialize a new map object with an existing Web Map item by entering it as the item argument, similarly to initializing with the previous class.

# Initialize in 2.4.x and after
from arcgis.map import Map

wm_item = gis.content.get("<web_map_id>")

wm = Map(
    item = wm_item
)
# Initialize in 2.3.x and prior
from arcgis.mapping import WebMap
wm = WebMap(
    webmapitem = item
)

The table below shows a mapping between previous WebMap class properties and methods and corresponding functionality in the new 2.4 release:

Methods:

WebMap operationMap operationNotes
wm.add_layer()m.content.add()new MapContent class method
wm.add_table()m.content.add()new MapContent class method
wm.basemap_title()m.basemap.titlenew BasemapManager class property
wm.configure_pop_ups()m.content.popup(index_position)new PopupManager class
wm.get_layer()m.content.layers[index_position]
wm.get_table()m.content.tables[index_position]
wm.move_from_basemap()m.basemap.move_from_basemap(layer_index)new BasemapManager class method
wm.move_to_basemap()m.content.move_to_basemap(layer_index)new MapContent class method
wm.print()m.print()
wm.remove_layer()m.content.remove(index_position)new MapContent class method
wm.remove_table()m.content.remove(index_position, False)new MapContent class method
wm.save()m.save()
wm.update()m.update()
wm.update_drawing_info()m.content.update_layer(renderer)new MapContent class method (update Renderer for layer)
wm.update_layer()m.update_layer()new MapContent class method

Properties

WebMap memberMap memberNotes
wm.basemapm.basemap.basemapnew BasemapManager class
wm.basemap_switcherNA
wm.basemapswm.basemap.basemap_galleryList
wm.basemapsm.basemap.basemapsproperty on new BasemapManager class
wm.bookmarksm.bookmarks.listlist property on new Bookmarks class
wm.eventsNA
wm.formsm.content.form()new MapContent class method (returns FormInfo for managing forms)
wm.gallery_basemapsm.basemap.basemap_gallerynew BasemapManager class property
wm.heightNA
wm.layer_visibilitym.layer_visibility=Truenew LayerVisibility widget
wm.layersm.content.layersnew MapContent class property
wm.legendm.legend.enabled=Truenew Legend widget
wm.navigationNA
wm.offline_areasm.offline_areasOfflineMapAreaManager
wm.pop_upsm.content.popups(layer_index).disable_popupnew PopupManager property
wm.scale_barNA
wm.searchNA
wm.tablesm.content.tablesnew MapContent class property
wm.view_bookmarksm.bookmarks.listnew Bookmarks class property
wm.widthNA
wm.zoomm.zoom

The arcgis.widgets module

The previous arcgis.widgets module contained the MapView class which served as the map widget in Jupyter notebooks. The Python API 2.4 release refactors the MapView functionality into two new classes in the arcgis.map module: Map and Scene classes.

In previous releases, maps and scenes were intialized based on the mode argument entered in the GIS.map() method, or by setting the mode property of a MapView object. Either way, you were always working with an instance of the MapView class. You can still use the mode argument when intializing the gis.map() object, but rather than returning the same type of object, the default value of 2D will return a Map object, and 3D will return a Scene object. Refactoring the calls allowed Python development to align with the web map specification and the web scene specification directly. This will increase widget compatibility within notebooks to more closely reflect the browser experiences of the Map Viewer and Scene Viewer.

Some properties and methods on the MapView class have been entirely removed, including interactive functionality that could be programmed into specific events like on_click and on_draw, embedding the widget into the notebook, and properties and methods that controlled the Jupyter environment. Other properties and methods have been refactored into new classes, many using the exact same name. See the table below for a mapping between previous MapView method and property names and how to access that functionality within the 2.4 release.

Note: In the table below, mview represents a variable to a MapView object, m represents a variable to a Map object, and scene to a Scene object.

Methods:

MapView class operationMap class operationNotes
mview.add_layer()m.content.add()new MapContent class method
mview.clear_graphics()m.content.remove_all()new MapContent class method
mview.display_message()NA
mview.draw()m.content.draw()
mview.embed()NA
mview.export_to_html()m.export_to_html()
mview.hide_mode_swich()NA
mview.on_click()NA
mview.on_draw_end()NA
mview.remove_layers()m.content.remove(index_position) also m.content.remove_all()new MapContent class
mview.save()m.save()
mview.set_js_cdnNA
mview.set_time_extent()m.time_slider.time_extent()new TimeSlider class method
mview.snap_to_zoom()NA
mview.sync_navigation()m.sync_navigation()
mview.take_screenshot()NA
mview.toggle_window_view()NA
mview.unsync_navigation()m.unsync_navigation()
mview.update()m.update()
mview.update_layer()m.content.update_layernew MapContent class method
mview.zoom_to_layer()m.zoom_to_layer()

Properties

MapView class memberMap class memberNotes
mview.basemapm.basemap.basemapnew BasemapManager class property
mview.basemapsm.basemap.basemapsnew BasemapManager class property
mview.centerm.center
mview.drawm.content.draw()
mview.end_timem.time_slider.time_extent()new TimeSlider class method
mview.extentm.extent
mview.gallery_basemapsm.basemap.basemap_gallerynew BasemapManager class property
mview.jupyter_targetNA
mview.headingscene.headingnew Scene class property
mview.layersm.content.layersnew MapContent class property
mview.legendm.legend.enabled = Truenew Legend widget
mview.local_raster_file_formatNA
mview.modegis.map(mode="2D" or "3D")* a parameter when initializing Map class
mview.print_service_urlNA
mview.readyNA
mview.rotationm.rotation
mview.scalem.scale
mview.start_timem.time_slider.time_extent()new TimeSlider class method
mview.tab_modeNA
mview.tiltscene.tiltnew Scene class property
mview.time_modem.time_slider.time_extent()new TimeSlider class method
mview.time_sliderm.time_slider.enabled=Truenew TimeSlider widget
mview.zoomm.zoom

New arcgis map Module

The Map class

The new map class was developed to align with the Jupyter Lab and Notebook 7 backend architecture and processing. The class includes properties which return auxiliary managment classes and interactive widget buttons for comprehensive management and visualization of a map and its content.

New widgets to provide increased visibility of the content on a rendered map in a Jupyter notebook:

The Scene Class

The new scene class was developed to align with the Jupyter Lab and Notebook 7 backend architecture and processing. The class includes properties which return auxiliary managment classes and interactive widget buttons for comprehensive management and visualization of a scene and its content.

  • content property - returns SceneContent object to manage the layers in a scene
  • basemap property - returns BasemapManager to manage the basemap for the scene

New widgets to provide enhanced visualization on a rendered Scene in a Jupyter notebook:

New arcgis.layers module

The Service class

The module also adds a new Service class designed to simplify getting specific types of services into the appropriate API object. No longer do you need to import a specific class into your scripts in order to initialize objects from url values to initialize the correct object. Now you can use the Service class to automatically determine the appropriate object type to return. Any service url entered as input will return an object of the corresponding class in the API. See below:

Most of the classes from the previous arcgis.mapping module have been refactored into this module. See the documentation above in the arcgis.mapping section for explanation.

# Previous releases:
from arcgis.features import FeatureLayerCollection
from arcgis.gis import GIS

gis = GIS(profile="your_online_profile")

fcoll = FeatureLayerCollection(
    url = "https://services5.arcgis.com/jmdi6ffhe45GMz1s/arcgis/rest/services/Groundwater_Ordinance_Areas/FeatureServer", 
    gis=gis
)

type(fcoll)
arcgis.features.layer.FeatureLayerCollection
# New at 2.4
from arcgis.layers import Service

fcoll = Service(
    url_or_item="https://services5.arcgis.com/jmdi6ffhe45GMz1s/arcgis/rest/services/Groundwater_Ordinance_Areas/FeatureServer",
    server=gis
)

print(type(fcoll))

service_obj = Service(
    url_or_item="https://mapservices.weather.noaa.gov/vector/rest/services/outlooks/natl_fcst_wx_chart/MapServer",
    server=gis
)

print(type(service_obj))

scene_obj = Service(
    url_or_item="https://tiles.arcgis.com/tiles/oPre3pOfRfefL8y0/arcgis/rest/services/swissbuildings3D/SceneServer"
)

print(type(scene_obj))
<class 'arcgis.features.layer.FeatureLayerCollection'>
<class 'arcgis.layers._msl.map_layers.MapImageLayer'>
<class 'arcgis.layers._scenelyrs._lyrs.Object3DLayer'>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.