arcgis.mapping module¶
The arcgis.mapping module provides components for visualizing GIS data and analysis. This module includes WebMap and WebScene components that enable 2D and 3D mapping and visualization in the GIS. This module also includes mapping layers like MapImageLayer, SceneLayer and VectorTileLayer.
WebMap¶
-
class
arcgis.mapping.
WebMap
(webmapitem=None)¶ Bases:
collections.OrderedDict
Represents a web map and provides access to its basemaps and operational layers as well as functionality to visualize and interact with them.
An ArcGIS web map is an interactive display of geographic information that you can use to tell stories and answer questions. Maps contain a basemap over which a set of data layers called operational layers are drawn. To learn more about web maps, refer: https://doc.arcgis.com/en/arcgis-online/reference/what-is-web-map.htm
Web maps can be used across ArcGIS apps because they adhere to the same web map specification. This means you can author web maps in one ArcGIS app (including the Python API) and view and modify them in another. To learn more about the web map specification, refer: https://developers.arcgis.com/web-map-specification/
Argument
Description
webmapitem
Optional Item object whose Item.type is ‘Web Map’. If not specified an empty WebMap object is created with some useful defaults.
# USAGE EXAMPLE 1: Creating a WebMap object from an existing web map item from arcgis.mapping import WebMap from arcgis.gis import GIS # connect to your GIS and get the web map item gis = GIS(url, username, password) wm_item = gis.content.get('1234abcd_web map item id') # create a WebMap object from the existing web map item wm = WebMap(wm_item) type(wm) >> arcgis.mapping._types.WebMap # explore the layers in this web map using the 'layers' property wm.layers >> [{}...{}] # returns a list of dictionaries representing each operational layer
-
add_layer
(layer, options=None)¶ Adds the given layer to the WebMap.
Argument
Description
layer
Required object. You can add any Layer objects such as FeatureLayer, MapImageLayer, ImageryLayer etc. You can also add Item objects and FeatureSet and FeatureCollections.
options
Optional dict. Specify properties such as title, symbol, opacity, visibility, renderer for the layer that is added. If not specified, appropriate defaults are applied.
# USAGE EXAMPLE: Add feature layer and map image layer item objects to the WebMap object. crime_fl_item = gis.content.search("2012 crime")[0] streets_item = gis.content.search("LA Streets","Map Service")[0] wm = WebMap() # create an empty web map with a default basemap wm.add_layer(streets_item) >> True # Add crime layer, but customize the title, transparency and turn off the default visibility. wm.add_layer(fl_item, {'title':'2012 crime in LA city', 'opacity':0.5, 'visibility':False}) >> True
- Returns
True if layer was successfully added. Else, raises appropriate exception.
-
property
basemap
¶ Base map layers in the web map :return: List of layers as dictionaries
-
property
layers
¶ Operational layers in the web map :return: List of Layers as dictionaries
# USAGE EXAMPLE 1: Get the list of layers from a web map from arcgis.mapping import WebMap wm = WebMap(wm_item) wm.layers >> [{"id": "Landsat8_Views_515", "layerType": "ArcGISImageServiceLayer", "url": "https://landsat2.arcgis.com/arcgis/rest/services/Landsat8_Views/ImageServer", ...}, {...}] len(wm.layers) >> 2
-
property
offline_areas
¶ Resource manager for offline areas cached for the web map :return:
-
remove_layer
(layer)¶ Removes the specified layer from the web map. You can get the list of layers in map using the ‘layers’ property and pass one of those layers to this method for removal form the map.
Argument
Description
layer
Required object. Pass the layer that needs to be removed from the map. You can get the list of layers in the map by calling the layers property.
-
save
(item_properties, thumbnail=None, metadata=None, owner=None, folder=None)¶ Save the WebMap object into a new web map Item in your GIS.
Note
If you started out with a fresh WebMap object, use this method to save it as a the web map item in your GIS.
If you started with a WebMap object from an existing web map item, calling this method will create a new item with your changes. If you want to update the existing web map item with your changes, call the update() method instead.
Argument
Description
item_properties
Required dictionary. See table below for the keys and values.
thumbnail
Optional string. Either a path or URL to a thumbnail image.
metadata
Optional string. Either a path or URL to the metadata.
owner
Optional string. Defaults to the logged in user.
folder
Optional string. Name of the folder into which the web map should be saved.
Key:Value Dictionary Options for Argument item_properties
Key
Value
typeKeywords
Optional string. Provide a lists all sub-types, see URL 1 below for valid values.
description
Optional string. Description of the item.
title
Optional string. Name label of the item.
tags
Optional string. Tags listed as comma-separated values, or a list of strings. Used for searches on items.
snippet
Optional string. Provide a short summary (limit to max 250 characters) of the what the item is.
accessInformation
Optional string. Information on the source of the content.
licenseInfo
Optional string. Any license information or restrictions regarding the content.
culture
Optional string. Locale, country and language information.
access
Optional string. Valid values are private, shared, org, or public.
commentsEnabled
Optional boolean. Default is true, controls whether comments are allowed (true) or not allowed (false).
culture
Optional string. Language and country information.
The above are the most common item properties (metadata) that you set. To get a complete list, see https://developers.arcgis.com/rest/users-groups-and-items/common-parameters.htm#ESRI_SECTION1_1FFBA7FE775B4BDA8D97524A6B9F7C98
- Returns
Item object corresponding to the new web map Item created.
# USAGE EXAMPLE 1: Save a WebMap object into a new web map item from arcgis.gis import GIS from arcgis.mapping import WebMap # log into your GIS gis = GIS(url, username, password) # compose web map by adding, removing, editing layers and basemaps wm = WebMap() # new web map wm.add_layer(...) # add some layers # save the web map webmap_item_properties = {'title':'Ebola incidents and facilities', 'snippet':'Map created using Python API showing locations of Ebola treatment centers', 'tags':['automation', 'ebola', 'world health', 'python']} new_wm_item = wm.save(webmap_item_properties, thumbnail='./webmap_thumbnail.png') # to visit the web map using a browser print(new_wm_item.homepage) >> 'https://your portal url.com/webadaptor/item.html?id=1234abcd...'
-
update
(item_properties=None, thumbnail=None, metadata=None)¶ Updates the web map item in your GIS with the changes you made to the WebMap object. In addition, you can update other item properties, thumbnail and metadata.
Note
If you started with a WebMap object from an existing web map item, calling this method will update the item with your changes.
If you started out with a fresh WebMap object (without a web map item), calling this method will raise a RuntimeError exception. If you want to save the WebMap object into a new web map item, call the save() method instead.
For item_properties, pass in arguments for the properties you want to be updated. All other properties will be untouched. For example, if you want to update only the item’s description, then only provide the description argument in item_properties.
Argument
Description
item_properties
Optional dictionary. See table below for the keys and values.
thumbnail
Optional string. Either a path or URL to a thumbnail image.
metadata
Optional string. Either a path or URL to the metadata.
Key:Value Dictionary Options for Argument item_properties
Key
Value
typeKeywords
Optional string. Provide a lists all sub-types, see URL 1 below for valid values.
description
Optional string. Description of the item.
title
Optional string. Name label of the item.
tags
Optional string. Tags listed as comma-separated values, or a list of strings. Used for searches on items.
snippet
Optional string. Provide a short summary (limit to max 250 characters) of the what the item is.
accessInformation
Optional string. Information on the source of the content.
licenseInfo
Optional string. Any license information or restrictions regarding the content.
culture
Optional string. Locale, country and language information.
access
Optional string. Valid values are private, shared, org, or public.
commentsEnabled
Optional boolean. Default is true, controls whether comments are allowed (true) or not allowed (false).
The above are the most common item properties (metadata) that you set. To get a complete list, see https://developers.arcgis.com/rest/users-groups-and-items/common-parameters.htm#ESRI_SECTION1_1FFBA7FE775B4BDA8D97524A6B9F7C98
- Returns
A boolean indicating success (True) or failure (False).
# USAGE EXAMPLE 1: Update an existing web map from arcgis.gis import GIS from arcgis.mapping import WebMap # log into your GIS gis = GIS(url, username, password) # edit web map by adding, removing, editing layers and basemaps wm = WebMap() # new web map wm.add_layer(...) # add some layers # save the web map webmap_item_properties = {'title':'Ebola incidents and facilities', 'snippet':'Map created using Python API showing locations of Ebola treatment centers', 'tags':['automation', 'ebola', 'world health', 'python']} new_wm_item = wm.save(webmap_item_properties, thumbnail='./webmap_thumbnail.png') # to visit the web map using a browser print(new_wm_item.homepage) >> 'https://your portal url.com/webadaptor/item.html?id=1234abcd...'
-
OfflineMapAreaManager¶
-
class
arcgis.mapping.
OfflineMapAreaManager
(item, gis)¶ Bases:
object
Helper class to manage offline map areas attached to a web map item. Users should not instantiate this class directly, instead, should access the methods exposed by accessing the offline_areas property on the WebMap object.
-
create
(area, item_properties=None, folder=None, min_scale=None, max_scale=None, layers_to_ignore=None)¶ Create offline map area items and packages for ArcGIS Runtime powered applications. This method creates two different types of items. It first creates ‘Map Area’ items for the specified extent or bookmark. Next it creates one or more map area packages corresponding to each layer type in the extent.
Note
Offline map area functionality is only available if your GIS is ArcGIS Online.
There can be only 1 map area item for an extent or bookmark.
You need to be the owner of the web map or an administrator of your GIS.
Argument
Description
area
Required object. You can specify the name of a web map bookmark or a desired extent.
To get the bookmarks from a web map, query the definition.bookmarks property.
You can specify the extent as a list or dictionary of ‘xmin’, ‘ymin’, ‘xmax’, ‘ymax’ and spatial reference. If spatial reference is not specified, it is assumed to be ‘wkid’ : 4326.
item_properties
Required dictionary. See table below for the keys and values.
folder
Optional string. Specify a folder name if you want the offline map area item and the packages to be created inside a folder.
min_scale
Optional number. Specify the minimum scale to cache tile and vector tile layers. When zoomed out beyond this scale, cached layers would not display.
max_scale
Optional number. Specify the maximum scale to cache tile and vector tile layers. When zoomed in beyond this scale, cached layers would not display.
layers_to_ignore
Optional List of layer objects to exclude when creating offline packages. You can get the list of layers in a web map by calling the layers property on the WebMap object.
Hint: Your min_scale is always bigger in value than your max_scale
Key:Value Dictionary Options for Argument item_properties
Key
Value
description
Optional string. Description of the item.
title
Optional string. Name label of the item.
tags
Optional string. Tags listed as comma-separated values, or a list of strings. Used for searches on items.
snippet
Optional string. Provide a short summary (limit to max 250 characters) of the what the item is.
- Returns
Item object for the offline map area item that was created.
USAGE EXAMPLE: Creating offline map areas wm = WebMap(wm_item) # create offline areas ignoring a layer and for certain min, max scales for other layers item_prop = {'title': 'Clear lake hyperspectral field campaign', 'snippet': 'Offline package for field data collection using spectro-radiometer', 'tags': ['python api', 'in-situ data', 'field data collection']} aviris_layer = wm.layers[-1] north_bed = wm.definition.bookmarks[-1]['name'] wm.offline_areas.create(extent=north_bed, item_properties=item_prop, folder='clear_lake', min_scale=9000, max_scale=4500, layers_to_ignore=[aviris_layer])
Note
This method executes silently. To view informative status messages, set the verbosity environment variable as shown below:
USAGE EXAMPLE: setting verbosity from arcgis import env env.verbose = True
-
list
()¶ Returns a list of Map Area items related to the current WebMap object.
Note
Map Area items and the corresponding offline packages cached for each share a relationship of type ‘Area2Package’. You can use this relationship to get the list of package items cached for a particular Map Area item. Refer to the Python snippet below for the steps:
USAGE EXAMPLE: Finding packages cached for a Map Area item from arcgis.mapping import WebMap wm = WebMap(a_web_map_item_object) all_map_areas = wm.offline_areas.list() # get all the offline areas for that web map area1 = all_map_areas[0] area1_packages = area1.related_items('Area2Package','forward') for pkg in area1_packages: print(pkg.homepage) # get the homepage url for each package item.
- Returns
List of Map Area items related to the current WebMap object
-
update
(offline_map_area_items=None)¶ Refreshes existing map area packages associated with the list of map area items specified. This process updates the packages with changes made on the source data since the last time those packages were created or refreshed.
Note
Offline map area functionality is only available if your GIS is ArcGIS Online.
You need to be the owner of the web map or an administrator of your GIS.
Argument
Description
offline_map_area_items
Optional list. Specify one or more Map Area items for which the packages need to be refreshed. If not specified, this method updates all the packages associated with all the map area items of the web map.
To get the list of Map Area items related to the WebMap object, call the list() method.
- Returns
Dictionary containing update status.
Note
This method executes silently. To view informative status messages, set the verbosity environment variable as shown below:
USAGE EXAMPLE: setting verbosity from arcgis import env env.verbose = True
-
WebScene¶
-
class
arcgis.mapping.
WebScene
(websceneitem)¶ Bases:
collections.OrderedDict
Represents a web scene and provides access to its basemaps and operational layers as well as functionality to visualize and interact with them.
If you would like more robust webscene authoring functionality, consider using the
MapView
class. You need to be using a Jupyter environment for the MapView class to function properly, but you can make copies of WebScenes, add layers using a simple add_layer() call, adjust the basemaps, save to new webscenes, and more.-
update
([E, ]**F) → None. Update D from dict/iterable E and F.¶ If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
-
MapImageLayer¶
-
class
arcgis.mapping.
MapImageLayer
(url, gis=None)¶ Bases:
arcgis.gis.Layer
MapImageLayer allows you to display and analyze data from sublayers defined in a map service, exporting images instead of features. Map service images are dynamically generated on the server based on a request, which includes an LOD (level of detail), a bounding box, dpi, spatial reference and other options. The exported image is of the entire map extent specified.
MapImageLayer does not display tiled images. To display tiled map service layers, see TileLayer.
-
create_dynamic_layer
(layer)¶ A dynamic layer / table method represents a single layer / table of a map service published by ArcGIS Server or of a registered workspace. This resource is supported only when the map image layer supports dynamic layers, as indicated by supportsDynamicLayers on the map image layer properties.
Argument
Description
layer
required dict. Dynamic layer/table source definition. Syntax: {
“id”: <layerOrTableId>, “source”: <layer source>, //required “definitionExpression”: “<definitionExpression>”, “drawingInfo”: {
“renderer”: <renderer>, “transparency”: <transparency>, “scaleSymbols”: <true,false>, “showLabels”: <true,false>, “labelingInfo”: <labeling info>
}, “layerTimeOptions”: //supported only for time enabled map layers {
“useTime” : <true,false>, “timeDataCumulative” : <true,false>, “timeOffset” : <timeOffset>, “timeOffsetUnits” : “<esriTimeUnitsCenturies,esriTimeUnitsDays,
esriTimeUnitsDecades,esriTimeUnitsHours, esriTimeUnitsMilliseconds,esriTimeUnitsMinutes, esriTimeUnitsMonths,esriTimeUnitsSeconds, esriTimeUnitsWeeks,esriTimeUnitsYears | esriTimeUnitsUnknown>”
}
}
- Returns
arcgis.features.FeatureLayer or None (if not enabled)
-
estimate_export_tiles_size
(export_by, levels, tile_package=False, export_extent='DEFAULTEXTENT', area_of_interest=None, asynchronous=True, **kwargs)¶ The estimate_export_tiles_size method is an asynchronous task that allows estimation of the size of the tile package or the cache data set that you download using the Export Tiles operation. This operation can also be used to estimate the tile count in a tile package and determine if it will exceced the maxExportTileCount limit set by the administrator of the service. The result of this operation is Map Service Job. This job response contains reference to Map Service Result resource that returns the total size of the cache to be exported (in bytes) and the number of tiles that will be exported.
Argument
Description
tile_package
optional boolean. Allows estimating the size for either a tile package or a cache raster data set. Specify the value true for tile packages format and false for Cache Raster data set. The default value is False
levels
required string. Specify the tiled service levels for which you want to get the estimates. The values should correspond to Level IDs, cache scales or the Resolution as specified in export_by parameter. The values can be comma separated values or a range. Example 1: 1,2,3,4,5,6,7,8,9 Example 2: 1-4,7-9
export_by
required string. The criteria that will be used to select the tile service levels to export. The values can be Level IDs, cache scales or the Resolution (in the case of image services). Values: LevelID, Resolution, Scale
export_extent
The extent (bounding box) of the tile package or the cache dataset to be exported. If extent does not include a spatial reference, the extent values are assumed to be in the spatial reference of the map. The default value is full extent of the tiled map service. Syntax: <xmin>, <ymin>, <xmax>, <ymax> Example: -104,35.6,-94.32,41
area_of_interest
optiona dictionary or Polygon. This allows exporting tiles within the specified polygon areas. This parameter supersedes extent parameter. Example: { “features”: [{“geometry”:{“rings”:[[[-100,35],
[-100,45],[-90,45],[-90,35],[-100,35]]], “spatialReference”:{“wkid”:4326}}}]}
asynchronous
optional boolean. The estimate function is run asynchronously requiring the tool status to be checked manually to force it to run synchronously the tool will check the status until the estimation completes. The default is True, which means the status of the job and results need to be checked manually. If the value is set to False, the function will wait until the task completes.
- Returns
dictionary
-
export_map
(bbox, bbox_sr=None, size='600, 550', dpi=200, image_sr=None, image_format='png', layer_defs=None, layers=None, transparent=False, time_value=None, time_options=None, dynamic_layers=None, gdb_version=None, scale=None, rotation=None, transformation=None, map_range_values=None, layer_range_values=None, layer_parameter=None, f='json', save_folder=None, save_file=None, **kwargs)¶ The export operation is performed on a map service resource. The result of this operation is a map image resource. This resource provides information about the exported map image such as its URL, its width and height, extent and scale.
- Returns
string, image of the map.
-
export_tiles
(levels, export_by='LevelID', tile_package=False, export_extent='DEFAULT', optimize_for_size=True, compression=75, area_of_interest=None, asynchronous=False, **kwargs)¶ The exportTiles operation is performed as an asynchronous task and allows client applications to download map tiles from a server for offline use. This operation is performed on a Map Service that allows clients to export cache tiles. The result of this operation is Map Service Job. This job response contains a reference to the Map Service Result resource, which returns a URL to the resulting tile package (.tpk) or a cache raster dataset. exportTiles can be enabled in a service by using ArcGIS for Desktop or the ArcGIS Server Administrator Directory. In ArcGIS for Desktop make an admin or publisher connection to the server, go to service properties, and enable Allow Clients to Export Cache Tiles in the advanced caching page of the Service Editor. You can also specify the maximum tiles clients will be allowed to download. The default maximum allowed tile count is 100,000. To enable this capability using the Administrator Directory, edit the service, and set the properties exportTilesAllowed=true and maxExportTilesCount=100000.
At 10.2.2 and later versions, exportTiles is supported as an operation of the Map Server. The use of the http://Map Service/exportTiles/submitJob operation is deprecated. You can provide arguments to the exportTiles operation as defined in the following parameters table:
Argument
Description
levels
required string. Specifies the tiled service levels to export. The values should correspond to Level IDs, cache scales. or the resolution as specified in export_by parameter. The values can be comma separated values or a range. Make sure tiles are present at the levels where you attempt to export tiles. Example 1: 1,2,3,4,5,6,7,8,9 Example 2: 1-4,7-9
export_by
required string. The criteria that will be used to select the tile service levels to export. The values can be Level IDs, cache scales. or the resolution. The defaut is ‘LevelID’. Values: LevelID | Resolution | Scale
tile_package
optiona boolean. Allows exporting either a tile package or a cache raster data set. If the value is true, output will be in tile package format, and if the value is false, a cache raster data set is returned. The default value is false.
export_extent
optional dictionary or string. The extent (bounding box) of the tile package or the cache dataset to be exported. If extent does not include a spatial reference, the extent values are assumed to be in the spatial reference of the map. The default value is full extent of the tiled map service. Syntax: <xmin>, <ymin>, <xmax>, <ymax> Example 1: -104,35.6,-94.32,41 Example 2: {“xmin” : -109.55, “ymin” : 25.76,
“xmax” : -86.39, “ymax” : 49.94, “spatialReference” : {“wkid” : 4326}}
optimize_for_size
optional boolean. Use this parameter to enable compression of JPEG tiles and reduce the size of the downloaded tile package or the cache raster data set. Compressing tiles slightly compromises the quality of tiles but helps reduce the size of the download. Try sample compressions to determine the optimal compression before using this feature. The default value is True.
compression=75,
optional integer. When optimize_for_size=true, you can specify a compression factor. The value must be between 0 and 100. The value cannot be greater than the default compression already set on the original tile. For example, if the default value is 75, the value of compressionQuality must be between 0 and 75. A value greater than 75 in this example will attempt to up sample an already compressed tile and will further degrade the quality of tiles.
area_of_interest
optional dictionary, Polygon. The area_of_interest polygon allows exporting tiles within the specified polygon areas. This parameter supersedes the exportExtent parameter. Example: { “features”: [{“geometry”:{“rings”:[[[-100,35],
[-100,45],[-90,45],[-90,35],[-100,35]]], “spatialReference”:{“wkid”:4326}}}]}
asynchronous
optional boolean. Default False, this value ensures the returns are returned to the user instead of the user having the check the job status manually.
- Returns
path to download file is asynchronous is False. If True, a dictionary is returned.
-
find
(search_text, layers, contains=True, search_fields=None, sr=None, layer_defs=None, return_geometry=True, max_offset=None, precision=None, dynamic_layers=None, return_z=False, return_m=False, gdb_version=None, return_unformatted=False, return_field_name=False, transformations=None, map_range_values=None, layer_range_values=None, layer_parameters=None, **kwargs)¶ performs the map service find operation
Argument
Description
search_text
required string.The search string. This is the text that is searched across the layers and fields the user specifies.
layers
optional string. The layers to perform the identify operation on. There are three ways to specify which layers to identify on:
top: Only the top-most layer at the specified location.
visible: All visible layers at the specified location.
all: All layers at the specified location.
contains
optional boolean. If false, the operation searches for an exact match of the search_text string. An exact match is case sensitive. Otherwise, it searches for a value that contains the search_text provided. This search is not case sensitive. The default is true.
search_fields
optional string. List of field names to look in.
sr
optional dict, string, or SpatialReference. The well-known ID of the spatial reference of the input and output geometries as well as the map_extent. If sr is not specified, the geometry and the map_extent are assumed to be in the spatial reference of the map, and the output geometries are also in the spatial reference of the map.
layer_defs
optional dict. Allows you to filter the features of individual layers in the exported map by specifying definition expressions for those layers. Definition expression for a layer that is published with the service will be always honored.
return_geometry
optional boolean. If true, the resultset will include the geometries associated with each result. The default is true.
max_offset
optional integer. This option can be used to specify the maximum allowable offset to be used for generalizing geometries returned by the identify operation.
precision
optional integer. This option can be used to specify the number of decimal places in the response geometries returned by the identify operation. This applies to X and Y values only (not m or z-values).
dynamic_layers
optional dict. Use dynamicLayers property to reorder layers and change the layer data source. dynamicLayers can also be used to add new layer that was not defined in the map used to create the map service. The new layer should have its source pointing to one of the registered workspaces that was defined at the time the map service was created. The order of dynamicLayers array defines the layer drawing order. The first element of the dynamicLayers is stacked on top of all other layers. When defining a dynamic layer, source is required.
return_z
optional boolean. If true, Z values will be included in the results if the features have Z values. Otherwise, Z values are not returned. The default is false.
return_m
optional boolean.If true, M values will be included in the results if the features have M values. Otherwise, M values are not returned. The default is false.
gdb_version
optional string. Switch map layers to point to an alternate geodatabase version.
return_unformatted
optional boolean. If true, the values in the result will not be formatted i.e. numbers will returned as is and dates will be returned as epoch values.
return_field_name
optional boolean. If true, field names will be returned instead of field aliases.
transformations
optional list. Use this parameter to apply one or more datum transformations to the map when sr is different than the map service’s spatial reference. It is an array of transformation elements.
map_range_values
optional list. Allows you to filter features in the exported map from all layer that are within the specified range instant or extent.
layer_range_values
optional dictionary. Allows you to filter features for each individual layer that are within the specified range instant or extent. Note: Check range infos at the layer resources for the available ranges.
layer_parameters
optional list. Allows you to filter the features of individual layers in the exported map by specifying value(s) to an array of pre-authored parameterized filters for those layers. When value is not specified for any parameter in a request, the default value, that is assigned during authoring time, gets used instead.
- Returns
dictionary
-
classmethod
fromitem
(item)¶ Returns the layer at the specified index from a layer item.
Argument
Description
item
Required string. An item ID representing a layer.
index
Optional int. The index of the layer amongst the item’s layers
- Returns
The layer at the specified index.
-
generate_kml
(save_location, name, layers, options='composite')¶ The generateKml operation is performed on a map service resource. The result of this operation is a KML document wrapped in a KMZ file. The document contains a network link to the KML Service endpoint with properties and parameters you specify.
Argument
Description
save_location
required string. Save folder.
name
The name of the resulting KML document. This is the name that appears in the Places panel of Google Earth.
layers
required string. the layers to perform the generateKML operation on. The layers are specified as a comma-separated list of layer ids.
options
required string. The layer drawing options. Based on the option chosen, the layers are drawn as one composite image, as separate images, or as vectors. When the KML capability is enabled, the ArcGIS Server administrator has the option of setting the layer operations allowed. If vectors are not allowed, then the caller will not be able to get vectors. Instead, the caller receives a single composite image. values: composite, separateImage, nonComposite
- Returns
string to file path
-
identify
(geometry, map_extent, image_display, geometry_type='Point', sr=None, layer_defs=None, time_value=None, time_options=None, layers='all', tolerance=None, return_geometry=True, max_offset=None, precision=4, dynamic_layers=None, return_z=False, return_m=False, gdb_version=None, return_unformatted=False, return_field_name=False, transformations=None, map_range_values=None, layer_range_values=None, layer_parameters=None, **kwargs)¶ The identify operation is performed on a map service resource to discover features at a geographic location. The result of this operation is an identify results resource. Each identified result includes its name, layer ID, layer name, geometry and geometry type, and other attributes of that result as name-value pairs.
- Returns
dictionary
-
property
item_info
¶ returns the service’s item’s infomation
-
property
kml
¶ returns the KML file for the layer
-
property
legend
¶ The legend resource represents a map service’s legend. It returns the legend information for all layers in the service. Each layer’s legend information includes the symbol images and labels for each symbol. Each symbol is an image of size 20 x 20 pixels at 96 DPI. Additional information for each layer such as the layer ID, name, and min and max scales are also included.
The legend symbols include the base64 encoded imageData as well as a url that could be used to retrieve the image from the server.
-
property
manager
¶
-
property
metadata
¶ returns the service’s XML metadata file
-
thumbnail
(out_path=None)¶ if present, this operation will download the image to local disk
-
MapImageLayerManager¶
-
class
arcgis.mapping.
MapImageLayerManager
(url, gis=None, map_img_lyr=None)¶ Bases:
arcgis.gis._GISResource
allows administration (if access permits) of ArcGIS Online hosted map image layers. A map image layer offers access to map and layer content.
-
cancel_job
(job_id)¶ The cancel job operation supports cancelling a job while update tiles is running from a hosted feature service. The result of this operation is a response indicating success or failure with error code and description.
- Inputs:
job_id - job id to cancel
-
delete_tiles
(levels, extent=None)¶ Deletes tiles for the current cache
Argument
Description
extent
optional dictionary, If specified, the tiles within this extent will be deleted or will be deleted based on the service’s full extent. Example: 6224324.092137296,487347.5253569535, 11473407.698535524,4239488.369818687 the minx, miny, maxx, maxy values or, {“xmin”:6224324.092137296,”ymin”:487347.5253569535, “xmax”:11473407.698535524,”ymax”:4239488.369818687, “spatialReference”:{“wkid”:102100}} the JSON representation of the Extent object.
levels
required string, The level to delete. Example, 0-5,10,11-20 or 1,2,3 or 0-5
- Returns
dictionary
-
edit_tile_service
(service_definition=None, min_scale=None, max_scale=None, source_item_id=None, export_tiles_allowed=False, max_export_tile_count=100000)¶ This operation updates a Tile Service’s properties
- Inputs:
service_definition - updates a service definition min_scale - sets the services minimum scale for caching max_scale - sets the service’s maximum scale for caching source_item_id - The Source Item ID is the GeoWarehouse Item ID of the map service export_tiles_allowed - sets the value to let users export tiles max_export_tile_count - sets the maximum amount of tiles to be exported
from a single call.
-
job_statistics
(job_id)¶ Returns the job statistics for the given jobId
-
refresh
(service_definition=True)¶ The refresh operation refreshes a service, which clears the web server cache for the service.
-
property
rerun_job
¶ The rerun job operation supports re-running a canceled job from a hosted map service. The result of this operation is a response indicating success or failure with error code and description.
Argument
Description
code
required string, parameter used to re-run a given jobs with a specific error code: ALL | ERROR | CANCELED
job_id
required string, job to reprocess
- Returns
boolean or dictionary
-
update_tiles
(levels=None, extent=None)¶ The starts tile generation for ArcGIS Online. The levels of detail and the extent are needed to determine the area where tiles need to be rebuilt.
..Note: This operation is for ArcGIS Online only.
Argument
Description
levels
Optional String / List of integers, The level of details to update. Example: “1,2,10,20” or [1,2,10,20]
extent
Optional String / Dict. The area to update as Xmin, YMin, XMax, YMax example: “-100,-50,200,500” or {‘xmin’:100, ‘ymin’:200, ‘xmax’:105, ‘ymax’:205}
- Returns
Dictionary. If the product is not ArcGIS Online tile service, the result will be None.
-
VectorTileLayer¶
-
class
arcgis.mapping.
VectorTileLayer
(url, gis=None)¶ Bases:
arcgis.gis.Layer
-
classmethod
fromitem
(item)¶ Returns the layer at the specified index from a layer item.
Argument
Description
item
Required string. An item ID representing a layer.
index
Optional int. The index of the layer amongst the item’s layers
- Returns
The layer at the specified index.
-
property
info
¶ This returns relative paths to a list of resource files
-
property
styles
¶
-
tile_fonts
(fontstack, stack_range)¶ This resource returns glyphs in PBF format. The template url for this fonts resource is represented in Vector Tile Style resource.
-
tile_sprite
(out_format='sprite.json')¶ This resource returns sprite image and metadata
-
vector_tile
(level, row, column)¶ This resource represents a single vector tile for the map. The bytes for the tile at the specified level, row and column are returned in PBF format. If a tile is not found, an error is returned.
-
classmethod
SceneLayer¶
-
class
arcgis.mapping.
SceneLayer
(url, gis=None)¶ Bases:
arcgis.gis.Layer
Represents a Web scene layer. Web scene layers are cached web layers that are optimized for displaying a large amount of 2D and 3D features. You can use scene layers to represent 3D points, point clouds, 3D objects and integrated mesh layers.
Argument
Description
url
Required string, specify the url ending in /SceneServer/
gis
Optional GIS object. If not specified, the active GIS connection is used.
# USAGE EXAMPLE 1: Instantiating a SceneLayer object from arcgis.mapping import SceneLayer s_layer = SceneLayer(url='https://your_portal.com/arcgis/rest/services/service_name/SceneServer/') type(s_layer) >> arcgis.mapping._types.SceneLayer print(s_layer.properties.layers[0].name) >> 'your layer name'
export_map¶
-
mapping.
export_map
(format: str = 'PDF', layout_template: str = 'MAP_ONLY', gis=None)¶ This function takes the state of the web map(for example, included services, layer visibility settings, client-side graphics, and so forth) and returns either (a) a page layout or (b) a map without page surrounds of the specified area of interest in raster or vector format. The input for this function is a piece of text in JavaScript object notation (JSON) format describing the layers, graphics, and other settings in the web map. The JSON must be structured according to the WebMap specification in the ArcGIS HelpThis tool is shipped with ArcGIS Server to support web services for printing, including the preconfigured service named PrintingTools. Parameters:
web_map_as_json: Web Map as JSON (str). Required parameter. A JSON representation of the state of the map to be exported as it appears in the web application. See the WebMap specification in the ArcGIS Help to understand how this text should be formatted. The ArcGIS web APIs (for JavaScript, Flex, Silverlight, etc.) allow developers to easily get this JSON string from the map.
- format: Format (str). Optional parameter. The format in which the map image for printing will be delivered. The following strings are accepted.For example:PNG8 (default if the parameter is left blank)PDFPNG32JPGGIFEPSSVGSVGZ
Choice list:[‘PDF’, ‘PNG32’, ‘PNG8’, ‘JPG’, ‘GIF’, ‘EPS’, ‘SVG’, ‘SVGZ’]
- layout_template: Layout Template (str). Optional parameter. Either a name of a template from the list or the keyword MAP_ONLY. When MAP_ONLY is chosen or an empty string is passed in, the output map does not contain any page layout surroundings (for example title, legends, scale bar, and so forth)
Choice list:[‘A3 Landscape’, ‘A3 Portrait’, ‘A4 Landscape’, ‘A4 Portrait’, ‘Letter ANSI A Landscape’, ‘Letter ANSI A Portrait’, ‘Tabloid ANSI B Landscape’, ‘Tabloid ANSI B Portrait’, ‘MAP_ONLY’]
gis: Optional, the GIS on which this tool runs. If not specified, the active GIS is used.
- Returns:
output_file - Output File as a DataFile
See https://utility.arcgisonline.com/arcgis/rest/directories/arcgisoutput/Utilities/PrintingTools_GPServer/Utilities_PrintingTools/ExportWebMapTask.htm for additional help.
get_layout_templates¶
-
mapping.
get_layout_templates
() → str¶ This function returns the content of the GIS’s layout templates formatted as dict.
Parameters:
gis: Optional, the GIS on which this tool runs. If not specified, the active GIS is used.
- Returns:
output_json - layout templates as Python dict
See https://utility.arcgisonline.com/arcgis/rest/directories/arcgisoutput/Utilities/PrintingTools_GPServer/Utilities_PrintingTools/GetLayoutTemplatesInfo.htm for additional help.