The arcgis.layers module provides components for visualizing GIS data and analysis. This module also includes mapping layers like MapImageLayer, SceneLayer and VectorTileLayer.
Service
- class arcgis.layers._service_factory.Service(url_or_item=None, server=None, initialize=False)
Bases:
object
The Service class allows users to pass a url string or an
Item
, along with an optionalGIS
connection or specificServer
object to return an instance of the specific ArcGIS API for Python object the service represents.Parameter
Description
url_or_item
Required String. Internet endpoint for the service to initialize as a Python object.
server
- Returns:
An object representing the service type of the input value.
# Usage Example: Directly from a url >>> from arcgis.gis import GIS >>> from arcgis.layers import Service >>> gis = GIS(profile="your_online_profile") >>> fs_url = "https://services7.arcgis.com/<org_id>/arcgis/rest/services/ancient_places/FeatureServer" >>> flc = Service( url_or_item=fs_url ) >>> flc <FeatureLayerCollection url:"https://services7.arcgis.com/<org_id>/arcgis/rest/services/ancient_places/FeatureServer"> >>> type(flc) arcgis.features.layer.FeatureLayerCollection # Usage Example #2: From an item >>> org_item = gis.content.get("_item_id_") >>> org_item.type Vector Tile Service >>> vts = Service( url_or_item=org_item ) >>> vts <VectorTileLayer url:"https://tiles.arcgis.com/tiles/<org_id>/arcgis/rest/services/Custom_Basemap_SXT/VectorTileServer">
BasemapServices
- class arcgis.layers.BasemapServices(gis=None)
Bases:
object
The basemap styles service is a ready-to-use location service that serves vector and image tiles that represent geographic features around the world. It includes styles that represent topographic features, road networks, footpaths, building footprints, water features, administrative boundaries, and satellite imagery. The styles are returned as JSON based on the Mapbox Style Specification or the ArcGIS Web Map Specification. The service also supports displaying localized language place labels, places, and worldviews. Custom basemap styles can also be created from the the default styles.
When you are using a rendered Map instance, you can specify the basemap service to the basemap property to apply the style to the map.
- property languages
Returns a list of supported languages for the basemap styles. To see which languages are supported by each service look at the documentation found here: https://developers.arcgis.com/rest/basemap-styles/
- property places
Returns a list of supported places for the basemap styles. To see which services support which places look at the documentation found here: https://developers.arcgis.com/rest/basemap-styles/
- property worldviews
Returns a list of supported worldviews for the basemap styles. To see which services support which worldviews look at the documentation found here: https://developers.arcgis.com/rest/basemap-styles/
BasemapService
Working with 3D Maps
SceneLayer
- class arcgis.layers.SceneLayer(url, gis=None)
Bases:
Layer
The
SceneLayer
class represents a Web scene layer.Note
Web scene layers are cached web layers that are optimized for displaying a large amount of 2D and 3D features.
Note
Web scene layers can be used to represent 3D points, point clouds, 3D objects and integrated mesh layers.
Parameter
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.layers import SceneLayer s_layer = SceneLayer(url='https://your_portal.com/arcgis/rest/services/service_name/SceneServer/') type(s_layer) >> arcgis.layers.PointCloudLayer print(s_layer.properties.layers[0].name) >> 'your layer name'
SceneLayerManager
- class arcgis.layers.SceneLayerManager(url, gis=None, scene_lyr=None)
Bases:
_GISResource
The
SceneLayerManager
class allows administration (if access permits) of ArcGIS Online hosted scene layers. ASceneLayerManager
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.Parameter
Description
job_id
Required String. The job id to cancel.
- edit(item)
The
edit
method edits from anItem
object.Parameter
Description
item
Required ItemId or
Item
object. The TPK file’s item id. This TPK file contains to-be-extracted bundle files which are then merged into an existing cache service.- Returns:
A dictionary
- import_package(item)
The
import
method imports from anItem
object.Parameter
Description
item
Required ItemId or
Item
object. The TPK file’s item id. This TPK file contains to-be-extracted bundle files which are then merged into an existing cache service.- Returns:
A dictionary
- jobs()
The tile service job summary (jobs) resource represents a summary of all jobs associated with a vector tile service. Each job contains a jobid that corresponds to the specific jobid run and redirects you to the Job Statistics page.
- rebuild_cache(layers)
The rebuild_cache operation update the scene layer cache to reflect any changes made to the feature layer used to publish this scene layer. The results of the operation is a response indicating success, which redirects you to the Job Statistics page, or failure.
Parameter
Description
layers
Required int or list of int. Comma separated values indicating the id of the layers to rebuild in the cache.
Ex: [0,1,2]
- refresh()
The
refresh
operation refreshes a service, which clears the web server cache for the service.
- rerun_job(job_id, code)
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.Parameter
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:
A boolean or dictionary
- swap(target_service_name)
The swap operation replaces the current service cache with an existing one.
Note
The
swap
operation is for ArcGIS Online only.Parameter
Description
target_service_name
Required string. Name of service you want to swap with.
- Returns:
dictionary indicating success or error
- update()
The
update
method starts update generation for ArcGIS Online. It updates the underlying source dataset for the service, essentially refreshing the underlying package data.- Returns:
Dictionary.
- update_attribute(layers)
Update atrribute is a “light rebuild” where attributes of the layers selected are updated and can be used for change tracking. The results of the operation is a response indicating success, which redirects you to the Job Statistics page, or failure.
Parameter
Description
layers
Required int or list of int. Comma separated values indicating the id of the layers to update in the cache.
Ex: [0,1,2]
- update_cache(layers)
Update Cache is a “light rebuild” where attributes and geometries of the layers selected are updated and can be used for change tracking on the feature layer to only update nodes with dirty tiles. The results of the operation is a response indicating success, which redirects you to the Job Statistics page, or failure.
Parameter
Description
layers
Required int or list of int. Comma separated values indicating the id of the layers to update in the cache.
Ex: [0,1,2]
EnterpriseSceneLayerManager
- class arcgis.layers.EnterpriseSceneLayerManager(url, gis=None, scene_lyr=None)
Bases:
_GISResource
The
EnterpriseSceneLayerManager
class allows administration (if access permits) of ArcGIS Enterprise hosted scene layers. ASceneLayer
offers access to layer content.Note
Url must be admin url such as:
https://services.myserver.com/arcgis/rest/admin/services/serviceName/SceneServer/
- change_provider(provider)
Allows for the switching of the service provide and how it is hosted on the ArcGIS Server instance.
Values:
‘ArcObjects’ means the service is running under the ArcMap runtime i.e. published from ArcMap
‘ArcObjects11’: means the service is running under the ArcGIS Pro runtime i.e. published from ArcGIS Pro
‘DMaps’: means the service is running in the shared instance pool (and thus running under the ArcGIS Pro provider runtime)
- Returns:
Boolean
- edit(service_dictionary)
To edit a service, you need to submit the complete JSON representation of the service, which includes the updates to the service properties. Editing a service causes the service to be restarted with updated properties.
- Returns:
boolean
- rebuild_cache(layer=None, extent=None, area_of_interest=None)
The rebuild_cache operation update the scene layer cache to reflect any changes made to the feature layer used to publish this scene layer. The results of the operation is the url to the scene service once it is done rebuilding.
Parameter
Description
layer
Optional list of integers. The list of layers to cook.
extent
Optional dict. The updated extent to be used. If nothing is specified, the default extent is used.
area_of_interest
Optional dict representing a feature. Specify the updated area of interest.
- Syntax:
- {
“displayFieldName”: “”, “geometryType”: “esriGeometryPolygon”, “spatialReference”: { “wkid”: 54051, “latestWkid”: 54051 }, “fields”: [ { “name”: “OID”, “type”: “esriFieldTypeOID”, “alias”: “OID” }, { “name”: “updateGeom_Length”, “type”: “esriFieldTypeDouble”, “alias”: “updateGeom_Length” }, { “name”: “updateGeom_Area”, “type”: “esriFieldTypeDouble”, “alias”: “updateGeom_Area” } ], “features”: [], “exceededTransferLimit”: False
}
- Returns:
If successful, the url to the scene service
- update_attribute(layer=None, extent=None, area_of_interest=None)
Update atrribute is a “light rebuild” where attributes of the layers selected are updated and can be used for change tracking. The results of the operation is the url to the scene service once it is done updating.
Parameter
Description
layer
Optional list of integers. The list of layers to cook.
extent
Optional dict. The updated extent to be used. If nothing is specified, the default extent is used.
area_of_interest
Optional dict representing a feature. Specify the updated area of interest.
- Syntax:
- {
“displayFieldName”: “”, “geometryType”: “esriGeometryPolygon”, “spatialReference”: { “wkid”: 54051, “latestWkid”: 54051 }, “fields”: [ { “name”: “OID”, “type”: “esriFieldTypeOID”, “alias”: “OID” }, { “name”: “updateGeom_Length”, “type”: “esriFieldTypeDouble”, “alias”: “updateGeom_Length” }, { “name”: “updateGeom_Area”, “type”: “esriFieldTypeDouble”, “alias”: “updateGeom_Area” } ], “features”: [], “exceededTransferLimit”: false
}
- Returns:
If successful, the url to the scene service
- update_cache(layer=None, extent=None, area_of_interest=None)
Update Cache is a “light rebuild” where attributes and geometries of the layers selected are updated and can be used for change tracking on the feature layer to only update nodes with dirty tiles,. The results of the operation is the url to the scene service once it is done updating.
Parameter
Description
layer
Optional list of integers. The list of layers to cook.
extent
Optional dict. The updated extent to be used. If nothing is specified, the default extent is used.
area_of_interest
Optional dict representing a feature. Specify the updated area of interest.
- Syntax:
- {
“displayFieldName”: “”, “geometryType”: “esriGeometryPolygon”, “spatialReference”: { “wkid”: 54051, “latestWkid”: 54051 }, “fields”: [ { “name”: “OID”, “type”: “esriFieldTypeOID”, “alias”: “OID” }, { “name”: “updateGeom_Length”, “type”: “esriFieldTypeDouble”, “alias”: “updateGeom_Length” }, { “name”: “updateGeom_Area”, “type”: “esriFieldTypeDouble”, “alias”: “updateGeom_Area” } ], “features”: [], “exceededTransferLimit”: False
}
- Returns:
If successful, the url to the scene service
BuildingLayer
- class arcgis.layers.BuildingLayer(url, gis=None)
Bases:
Layer
The
BuildingLayer
class represents a Web building layer.Note
Web scene layers are cached web layers that are optimized for displaying a large amount of 2D and 3D features. See the
SceneLayer
class for more information.Parameter
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.layers import SceneLayer s_layer = SceneLayer(url='https://your_portal.com/arcgis/rest/services/service_name/SceneServer/') type(s_layer) >> arcgis.layers.BuildingLayer print(s_layer.properties.layers[0].name) >> 'your layer name'
- property manager
The
manager
property returns an instance ofSceneLayerManager
class orEnterpriseSceneLayerManager
class which provides methods and properties for administering this service.
IntegratedMeshLayer
- class arcgis.layers.IntegratedMeshLayer(url, gis=None)
Bases:
Layer
The
IntegratedMeshLayer
class represents a Web scene Integrated Mesh layer.Note
Web scene layers are cached web layers that are optimized for displaying a large amount of 2D and 3D features. See the
SceneLayer
class for more information.Parameter
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.layers import SceneLayer s_layer = SceneLayer(url='https://your_portal.com/arcgis/rest/services/service_name/SceneServer/') type(s_layer) >> arcgis.layers.Point3DLayer print(s_layer.properties.layers[0].name) >> 'your layer name'
- property manager
The
manager
property returns an instance ofSceneLayerManager
class orEnterpriseSceneLayerManager
class which provides methods and properties for administering this service.
Tiles3DLayer
- class arcgis.layers.Tiles3DLayer(url, gis=None)
Bases:
Layer
The
Tiles3DLayer
class represents a Web scene 3D Tile Service Layer.Note
Web scene layers are cached web layers that are optimized for displaying a large amount of 2D and 3D features. See the
SceneLayer
class for more information.Parameter
Description
url
Required string, specify the url ending in /3DTilesServer/
gis
Optional
GIS
object. If not specified, the active GIS connection is used.
Object3DLayer
- class arcgis.layers.Object3DLayer(url, gis=None)
Bases:
Layer
The
Object3DLayer
represents a Web scene 3D Object layer.Note
Web scene layers are cached web layers that are optimized for displaying a large amount of 2D and 3D features. See the
SceneLayer
class for more information.Parameter
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.layers import SceneLayer s_layer = SceneLayer(url='https://your_portal.com/arcgis/rest/services/service_name/SceneServer/') type(s_layer) >> arcgis.layers.Point3DLayer print(s_layer.properties.layers[0].name) >> 'your layer name'
- property manager
The
manager
property returns an instance ofSceneLayerManager
class orEnterpriseSceneLayerManager
class which provides methods and properties for administering this service.
Point3DLayer
- class arcgis.layers.Point3DLayer(url, gis=None)
Bases:
Layer
The
Point3DLayer
class represents a Web scene 3D Point layer.Note
Web scene layers are cached web layers that are optimized for displaying a large amount of 2D and 3D features. See the
SceneLayer
class for more information.Parameter
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.layers import SceneLayer s_layer = SceneLayer(url='https://your_portal.com/arcgis/rest/services/service_name/SceneServer/') type(s_layer) >> arcgis.layers.Point3DLayer print(s_layer.properties.layers[0].name) >> 'your layer name'
- property manager
The
manager
property returns an instance ofSceneLayerManager
class orEnterpriseSceneLayerManager
class which provides methods and properties for administering this service.
PointCloudLayer
- class arcgis.layers.PointCloudLayer(url, gis=None)
Bases:
Layer
The
PointCloudLayer
class represents a Web scene Point Cloud layer.Note
Point Cloud layers are cached web layers that are optimized for displaying a large amount of 2D and 3D features. See the
SceneLayer
class for more information.Parameter
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.layers import SceneLayer s_layer = SceneLayer(url='https://your_portal.com/arcgis/rest/services/service_name/SceneServer/') type(s_layer) >> arcgis.layers.PointCloudLayer print(s_layer.properties.layers[0].name) >> 'your layer name'
- property manager
The
manager
property returns an instance ofSceneLayerManager
class orEnterpriseSceneLayerManager
class which provides methods and properties for administering this service.
VoxelLayer
- class arcgis.layers.VoxelLayer(url, gis=None)
Bases:
Layer
The
VoxelLayer
class represents a Web Scene Voxel layer.Note
Web scene layers are cached web layers that are optimized for displaying a large amount of 2D and 3D features. See the
SceneLayer
class for more information.Parameter
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.layers import SceneLayer s_layer = SceneLayer(url='https://your_portal.com/arcgis/rest/services/service_name/SceneServer/') type(s_layer) >> arcgis.layers.VoxelLayer print(s_layer.properties.layers[0].name) >> 'your layer name'
- property manager
The
manager
property returns an instance ofSceneLayerManager
class orEnterpriseSceneLayerManager
class which provides methods and properties for administering this service.
Working with Map Service Layers
MapServiceLayer
- class arcgis.layers.MapServiceLayer(url, gis=None, container=None, dynamic_layer=None)
Bases:
Layer
The
MapServiceLayer
class is a factory that generates the Map Service Layers.Parameter
Description
url
Required string, specify the url ending in /MapServer/<index>
gis
Optional
GIS
object. If not specified, the active GIS connection is used.# USAGE EXAMPLE 1: Instantiating a Map Service Layer object from arcgis.layers import MapServiceLayer ms_layer = MapServiceLayer(url='https://your_portal.com/arcgis/rest/services/service_name/MapServer/0') type(ms_layer) >> arcgis.layers.MapTable print(ms_layer.properties.name) >> 'pipe_properties'
MapFeatureLayer
- class arcgis.layers.MapFeatureLayer(url, gis=None, container=None, dynamic_layer=None, time_filter=None)
Bases:
Layer
The
MapFeatureLayer
class represents Map Feature Layers. Map Feature Layers can be added to and visualized using maps.Map Feature Layers are created by publishing feature data to a
GIS
, and are exposed as a broader resource (Item
) in theGIS
. MapFeatureLayer objects can be obtained through the layers attribute on map image service Items in theGIS
.- property attachements
The
attachments
property provides a manager to work with attachments if theMapFeatureLayer
supports this functionality.
- property container
The
container
property represents theMapImageLayer
to which this layer belongs.
- export_attachments(output_folder, label_field=None)
The
export_attachments
method exports attachments from the map feature layer inImagenet
format using theoutput_label_field
.Parameter
Description
output_folder
Required String. Output folder path where the attachments will be stored.
label_field
Optional. Field which contains the label/category of each feature. If None, a default folder is created.
- Returns:
A path to the exported attachments
- classmethod fromitem(item, layer_id=0)
The
fromitem
method creates aMapFeatureLayer
from a GISItem
.Parameter
Description
item
Required
Item
object. The type of item should be aMapServiceLayer
object.layer_id
Optional integer. The id of the layer in the Map Service’s Layer. The default is 0.
- Returns:
A
MapFeatureLayer
object
# USAGE EXAMPLE >>> from arcgis.layers import MapImageLayer, MapFeatureLayer >>> from arcgis.gis import GIS # connect to your GIS and get the web map item >>> gis = GIS(url, username, password) >>> map_image_item = gis.content.get("2aaddab96684405880d27f5261125061") >>> map_feature_layer = MapFeatureLayer.fromitem(item = map_image_item, layer_id = 2) >>> print(f"{map_feature_layer.properties.name:30}{type(map_feature_layer)}") <State Boundaries <class 'arcgis.layers._msl.layer.MapFeatureLayer'>>
- generate_renderer(definition, where=None)
The
generate_renderer
operation groups data using the supplied definition (classification definition) and an optional where clause. The result is a renderer object. UsebaseSymbol
andcolorRamp
to define the symbols assigned to each class.Note
If the operation is performed on a table, the result is a renderer object containing the data classes and no symbols.
Parameter
Description
definition
Required dict. The definition using the renderer that is generated. Use either class breaks or unique value classification definitions. See the classification definitions page in the ArcGIS REST API documentation for more information.
where
Optional string. A where clause for which the data needs to be classified. Any legal SQL where clause operating on the fields in the dynamic layer/table is allowed.
- Returns:
dictionary
- get_html_popup(oid)
The
get_html_popup
resource provides details about the HTML pop-up authored by the user using ArcGIS Pro or ArcGIS Desktop.Parameter
Description
oid
Optional string. Object id of the feature to get the HTML popup.
- Returns:
A string
- get_unique_values(attribute, query_string='1=1')
The
get_unique_values
method retrieves a list of unique values for a given attribute.Parameter
Description
attribute
Required string. The map feature layer attribute to query.
query_string
Optional string. SQL Query that will be used to filter attributes before unique values are returned.
- Returns:
A List
# USAGE EXAMPLE >>> from arcgis.layers import MapImageLayer, MapFeatureLayer >>> from arcgis.gis import GIS # connect to your GIS and get the web map item >>> gis = GIS(url, username, password) >>> map_image_item = gis.content.get("2aaddab96684405880d27f5261125061") >>> map_feature_layer = MapFeatureLayer.fromitem(item = map_image_item, layer_id = 2) >>> unique_values = map_feature_layer.get_unique_values(attribute ="Name", query_string ="name_2 like '%K%'") >>> type(unique_values) <List>
- query(where='1=1', text=None, out_fields='*', time_filter=None, geometry_filter=None, return_geometry=True, return_count_only=False, return_ids_only=False, return_distinct_values=False, return_extent_only=False, group_by_fields_for_statistics=None, statistic_filter=None, result_offset=None, result_record_count=None, object_ids=None, distance=None, units=None, max_allowable_offset=None, out_sr=None, geometry_precision=None, gdb_version=None, order_by_fields=None, out_statistics=None, return_z=False, return_m=False, multipatch_option=None, quantization_parameters=None, return_centroid=False, return_all_records=True, result_type=None, historic_moment=None, sql_format=None, return_true_curves=False, return_exceeded_limit_features=None, as_df=False, datum_transformation=None, range_values=None, parameter_values=None, **kwargs)
The
query
method queries a map feature layer based on a sql statement.Parameter
Description
where
Optional string. The default is 1=1. The selection sql statement.
text
Optional String. A literal search text. If the layer has a display field associated with it, the server searches for this text in this field.
out_fields
Optional List of field names to return. Field names can be specified either as a List of field names or as a comma separated string. The default is “*”, which returns all the fields.
object_ids
Optional string. The object IDs of this layer or table to be queried. The object ID values should be a comma-separated string.
distance
Optional integer. The buffer distance for the input geometries. The distance unit is specified by units. For example, if the distance is 100, the query geometry is a point, units is set to meters, and all points within 100 meters of the point are returned.
units
Optional string. The unit for calculating the buffer distance. If unit is not specified, the unit is derived from the geometry spatial reference. If the geometry spatial reference is not specified, the unit is derived from the feature service data spatial reference. This parameter only applies if supportsQueryWithDistance is true.
- Value options:
esriSRUnit_Meter
|esriSRUnit_StatuteMile
|esriSRUnit_Foot
|esriSRUnit_Kilometer
|esriSRUnit_NauticalMile
|esriSRUnit_USNauticalMile
time_filter
Optional list of startTime and endTime values. :Syntax:
>>> time_filter=[<startTime>, <endTime>]
Note
Specified as
_dt.datetime.date
,_dt.datetime._dt.datetime
ortimestamp
in millisecondsgeometry_filter
Optional
filter
object. Allows for the information to be filtered on spatial relationship with another geometry.max_allowable_offset
Optional float. This option can be used to specify the max_allowable_offset to be used for generalizing geometries returned by the query operation in the units of out_sr. If out_sr is not specified, the value is in units of the spatial reference of the layer.
out_sr
Optional Integer. The WKID for the spatial reference of the returned geometry.
geometry_precision
Optional Integer. This option can be used to specify the number of decimal places in the response geometries returned by the query operation. This applies to X and Y values only (not m or z-values).
gdb_version
Optional string. The geodatabase version to query. This parameter applies only if the isDataVersioned property of the layer is true. If not specified, the query will apply to the published map’s version.
return_geometry
Optional boolean. If true, geometry is returned with the query. Default is true.
return_distinct_values
Optional boolean. If True, it returns distinct values based on fields specified in out_fields. This parameter applies only if the supportsAdvancedQueries property of the layer is true.
return_ids_only
Optional boolean. Default is False. If True, the response only includes an array of object IDs. Otherwise, the response is a
FeatureSet
.return_count_only
Optional boolean. If True, the response only includes the count of features/records satisfying the query. Otherwise, the response is a
FeatureSet
. The default is False. This option supersedes the returns_ids_only parameter. IfreturnCountOnly = True
, the response will return both the count and the extent.return_extent_only
Optional boolean. If True, the response only includes the extent of the features satisying the query. If returnCountOnly=true, the response will return both the count and the extent. The default is False. This parameter applies only if the supportsReturningQueryExtent property of the layer is true.
order_by_fields
Optional string. One or more field names by which to order the results. Use
ASC
orDESC
for ascending or descending, respectively, following every field to be ordered:>>> order_by_fields = "STATE_NAME ASC, RACE DESC, GENDER ASC"
group_by_fields_for_statistics
Optional string. One or more field names on which to group results for calculating the statistics.
>>> group_by_fields_for_statiscits = "STATE_NAME, GENDER"
out_statistics
Optional List. The definitions for one or more field-based statistics to be calculated.
- Syntax:
>>> out_statistics = [ { "statisticType": "<count | sum | min | max | avg | stddev | var>", "onStatisticField": "Field1", "outStatisticFieldName": "Out_Field_Name1" }, { "statisticType": "<count | sum | min | max | avg | stddev | var>", "onStatisticField": "Field2", "outStatisticFieldName": "Out_Field_Name2" } ]
return_z
Optional boolean. If True, Z values are 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 are included in the results if the features have M values. Otherwise, M values are not returned. The default is False.
multipatch_option
Optional x/y footprint. This option dictates how the geometry of a multipatch feature will be returned.
result_offset
Optional integer. This option can be used for fetching query results by skipping the specified number of records and starting from the next record (that is, resultOffset + ith value). This option is ignored if return_all_records is True (i.e. by default).
result_record_count
Optional integer. This option can be used for fetching query results up to the result_record_count specified. When result_offset is specified but this parameter is not, the map service defaults it to max_record_count. The maximum value for this parameter is the value of the layer’s maxRecordCount property. This option is ignored if return_all_records is True (i.e. by default).
quantization_parameters
Optional dict. Used to project the geometry onto a virtual grid, likely representing pixels on the screen.
return_centroid
Optional boolean. Used to return the geometry centroid associated with each feature returned. If True, the result includes the geometry centroid. The default is False.
return_all_records
Optional boolean. When True, the query operation will call the service until all records that satisfy the where_clause are returned.
Note
result_offset and result_record_count will be ignored if set to True. If return_count_only, return_ids_only, or return_extent_only are True, this parameter is ignored.
result_type
Optional string. Controls the number of features returned by the operation. Options:
None
|standard
|tile
Note
See Query (Feature Service/Layer) for full explanation.
historic_moment
Optional integer. The historic moment to query. This parameter applies only if the layer is archiving enabled and the supportsQueryWithHistoricMoment property is set to true. This property is provided in the layer’s
properties
resource. If not specified, the query will apply to the current features.sql_format
Optional string. The sql_format parameter can be either standard SQL92 or it can use the native SQL of the underlying datastore. The default is None, which means it depends on the useStandardizedQuery layer property. Values:
None
|standard
|native
return_true_curves
Optional boolean. When set to True, returns true curves in output geometries. When set to False, curves are converted to densified polylines or polygons.
return_exceeded_limit_features
Optional boolean. Optional parameter which is true by default. When set to true, features are returned even when the results include the exceededTransferLimit: True property.
When set to False and querying with resultType = tile, features are not returned when the results include exceededTransferLimit: True. This allows a client to find the resolution in which the transfer limit is no longer exceeded without making multiple calls.
as_df
Optional boolean. If True, the results are returned as a DataFrame instead of a
FeatureSet
.datum_transformation
Optional Integer/Dictionary. This parameter applies a datum transformation while projecting geometries in the results when out_sr is different than the layer’s spatial reference. When specifying transformations, you need to think about which datum transformation best projects the layer (not the feature service) to the outSR and sourceSpatialReference property in the layer properties. For a list of valid datum transformation ID values ad well-known text strings, see Coordinate systems and transformations. For more information on datum transformations, please see the transformation parameter in the Project operation.
Example:
Inputs
Description
WKID
Integer.
>>> datum_transformation=4326
WKT
Dict.
>>> datum_transformation = {"wkt": "<WKT>"}
Composite
Dict.
>>> datum_transformation = {"geoTransforms" : [ {"wkid" : "<id>", "forward" : True | False}, {"wkt" : "WKT", "forward" : True: False} ] }
range_values
Optional List. Allows you to filter features from the layer that are within the specified range instant or extent.
>>> range_values = [ { "name": "range name" , # single value or a value-range "value": <value> or [ <value1>, <value2> ] }, { "name": "range name 2", "value": <value> or [ <value3>, <value4> ] } ]
Note
None is allowed in value-range case to indicate infinity
# all features with values <= 1500 >>> range_values = [ {"name" : "range name", "value" : [None, 1500]} ] # all features with values >= 1000 >>> range_values = [ {"name" : "range name", "value" : [1000, None]} ]
parameter_values
Optional Dict. Allows you to filter the layers 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.
When a parameterInfo allows multiple values, you must pass them in an array.
Note
Check parameterValues at the Query (Map Service/Layer) for details on parameterized filters.
kwargs
Optional dict. Optional parameters that can be passed to the Query function. This will allow users to pass additional parameters not explicitly implemented on the function. A complete list of functions available is documented at Query (Feature Service/Layer).
- Returns:
A
FeatureSet
containing the features matching the query unless another
return type is specified, such as
count
.# USAGE EXAMPLE >>> from arcgis.layers import MapImageLayer, MapFeatureLayer >>> from arcgis.gis import GIS # connect to your GIS and get the web map item >>> gis = GIS(url, username, password) >>> map_image_item = gis.content.get("2aaddab96684405880d27f5261125061") >>> map_feature_layer = MapFeatureLayer.fromitem(item = map_image_item, layer_id = 2) >>> query_count = map_feature_layer.query(where "1=1", text = "Hurricane Data", units = "esriSRUnit_Meter", return_count_only = True, out_statistics = [ { "statisticType": "count", "onStatisticField": "Field1", "outStatisticFieldName": "Out_Field_Name1" }, { "statisticType": "avg", "onStatisticField": "Field2", "outStatisticFieldName": "Out_Field_Name2" } ], range_values= [ { "name": "range name", "value": [None, 1500] }, { "name": "range name 2", "value":[1000, None] } } ] ) >>> query_count <149>
The
query_related_records
operation is performed on aMapFeatureLayer
resource. The result of this operation areFeatureSet
objects grouped by source layer/table object IDs. EachFeatureSet
containsFeature
objects including the values for the fields requested by the user.Note
For related layers, if you request geometry information, the geometry of each feature is also returned in the feature set. For related tables, the feature set does not include geometries.
Note
See the
query
method for more information.Parameter
Description
object_ids
Required string. The object IDs of the table/layer to be queried
relationship_id
Required string. The ID of the relationship to be queried.
out_fields
Required string. the list of fields from the related table/layer to be included in the returned feature set. This list is a comma delimited list of field names. If you specify the shape field in the list of return fields, it is ignored. To request geometry, set return_geometry to true. You can also specify the wildcard “*” as the value of this parameter. In this case, the results will include all the field values.
definition_expression
Optional string. The definition expression to be applied to the related table/layer. From the list of objectIds, only those records that conform to this expression are queried for related records.
return_geometry
Optional boolean. If true, the feature set includes the geometry associated with each feature. The default is true.
max_allowable_offset
Optional float. This option can be used to specify the max_allowable_offset to be used for generalizing geometries returned by the query operation. The max_allowable_offset is in the units of the outSR. If out_wkid is not specified, then max_allowable_offset is assumed to be in the unit of the spatial reference of the map.
geometry_precision
Optional integer. This option can be used to specify the number of decimal places in the response geometries.
out_wkid
Optional Integer. The spatial reference of the returned geometry.
gdb_version
Optional string. The geodatabase version to query. This parameter applies only if the isDataVersioned property of the layer queried is true.
return_z
Optional boolean. If true, Z values are 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 are included in the results if the features have M values. Otherwise, M values are not returned. The default is false.
historic_moment
Optional Integer/_dt.datetime. The historic moment to query. This parameter applies only if the supportsQueryWithHistoricMoment property of the layers being queried is set to true. This setting is provided in the layer resource.
If historic_moment is not specified, the query will apply to the current features.
- Syntax:
historic_moment=<Epoch time in milliseconds>
return_true_curves
Optional boolean. Optional parameter that is false by default. When set to true, returns true curves in output geometries; otherwise, curves are converted to densified polylines or polygons.
- Returns:
dict
- property renderer
Get/Set the Renderer of the Map Feature Layer.
Note
The
renderer
property overrides the default symbology when displaying it on aMap
.- Returns:
A
dict
object used to update and alter JSON
- property time_filter
Starting at Enterprise 10.7.1+, instead of querying time-enabled map service layers or time-enabled feature service layers, a time filter can be set using the
time_filter
property. Time can be filtered as Python _dt.datetime, objects or strings representing Unix epoch values in milliseconds. An extent can be specified by separating the start and stop values comma.>>> import _dt.datetime as dt >>> map_feature_lyr.time_filter = [dt._dt.datetime(2021, 1, 1), dt._dt.datetime(2022, 1, 10)]
MapRasterLayer
- class arcgis.layers.MapRasterLayer(url, gis=None, container=None, dynamic_layer=None, time_filter=None)
Bases:
MapFeatureLayer
The
MapRasterLayer
class represents a geo-referenced image hosted in aMap Service
.
MapImageLayer
- class arcgis.layers.MapImageLayer(url, gis=None)
Bases:
Layer
The
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.Note
MapImageLayer
does not display tiled images. To display tiled map service layers, seeTileLayer
.- create_dynamic_layer(layer)
The
create_dynamic_layer
method creates a dynamic layer. A dynamic layer / table 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 bysupportsDynamicLayers
on the map image layer properties.Parameter
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:
FeatureLayer
or None (if not enabled)
# USAGE EXAMPLE >>> from arcgis.layers import MapImageLayer >>> from arcgis.gis import GIS # connect to your GIS and get the web map item >>> gis = GIS(url, username, password) >>> map_image_item = gis.content.get("2aaddab96684405880d27f5261125061") >>> layer_to_add ={ "id": <layerId>, "source": <layer source> "definitionExpression": "<definitionExpression>", "drawingInfo": { "renderer": <renderer>, "transparency": <transparency>, "scaleSymbols": <true>, "showLabels": <true>, "labelingInfo": <labeling info> }, "layerTimeOptions": { "useTime" : <true,false>, "timeDataCumulative" : <true>, "timeOffset" : <timeOffset>, "timeOffsetUnits" : "<esriTimeUnitsCenturies>" } } >>> new_layer = map_image_item.create_dynamic_layer(layer= layer_to_add) >>>type(new_layer) <arcgis.features.FeatureLayer>
- estimate_export_tiles_size(export_by, levels, tile_package=False, export_extent='DEFAULT', 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 theexport_tiles
operation. This operation can also be used to estimate the tile count in a tile package and determine if it will exceed themaxExportTileCount
limit set by the administrator of the service. The result of this operation isMapServiceJob
. This job response contains reference toMap 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.Parameter
Description
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”
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
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
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
Optional 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_map
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.Parameter
Description
bbox
Required string. The extent (bounding box) of the exported image. Unless the bbox_sr parameter has been specified, the bbox is assumed to be in the spatial reference of the map.
bbox_sr
Optional integer,
SpatialReference
. The spatial reference of the bbox.size
Optional string. size - size of image in pixels
dpi
Optional integer. dots per inch
image_sr
Optional integer,
SpatialReference
. The spatial reference of the output image.image_format
Optional string. The format of the exported image. The default format is .png. Values:
png | png8 | png24 | jpg | pdf | bmp | gif | svg | svgz | emf | ps | png32
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.
layers
Optional string. Determines which layers appear on the exported map. There are four ways to specify which layers are shown:
show
: Only the layers specified in this list will be exported.hide
: All layers except those specified in this list will be exported.include
: In addition to the layers exported by default, the layers specified in this list will be exported.exclude
: The layers exported by default excluding those specified in this list will be exported.transparent
Optional boolean. If true, the image will be exported with the background color of the map set as its transparent color. The default is false.
Note
Only the .png and .gif formats support transparency.
time_value
Optional list. The time instant or the time extent of the features to be identified.
time_options
Optional dict. The time options per layer. Users can indicate whether or not the layer should use the time extent specified by the time parameter or not, whether to draw the layer features cumulatively or not and the time offsets for the layer.
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.
gdb_version
Optional string. Switch map layers to point to an alternate geodatabase version.
scale
Optional float. Use this parameter to export a map image at a specific map scale, with the map centered around the center of the specified bounding box (bbox)
rotation
Optional float. Use this parameter to export a map image rotated at a specific angle, with the map centered around the center of the specified bounding box (bbox). It could be positive or negative number.
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_parameter
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:
A string, image of the map.
# USAGE EXAMPLE >>> from arcgis.layers import MapImageLayer >>> from arcgis.gis import GIS # connect to your GIS and get the web map item >>> gis = GIS(url, username, password) >>> map_image_item = gis.content.get("2aaddab96684405880d27f5261125061") >>> map_image_item.export_map(bbox="-104,35.6,-94.32,41", bbox_sr = 4326, image_format ="png", layers = "include", transparent = True, scale = 40.0, rotation = -45.0 )
- export_tiles(levels, export_by='LevelID', tile_package=True, export_extent=None, optimize_for_size=True, compression=75, area_of_interest=None, asynchronous=False, storage_format=None, **kwargs)
The
export_Tiles
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 aMap Service
that allows clients to export cache tiles. The result of this operation is aMap Service Job
. This job response contains a reference to theMap Service Result
resource, which returns a URL to the resulting tile package (.tpk) or a cache raster dataset.export_Tiles
can be enabled in a service by using ArcGIS Desktop or the ArcGIS Server Administrator Directory. In ArcGIS Desktop make an admin or publisher connection to the server, go to service properties, and enableAllow Clients
toExport Cache Tiles
in the advanced caching page of theService Editor
. You can also specify the maximum tiles clients will be allowed to download.Note
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
andmaxExportTilesCount
= 100000.Note
In ArcGIS Server 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:Parameter
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 default is ‘LevelID’. Values:
levelId | resolution | scale
tile_package
Optional 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 True.
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.
storage_format
Optional string. Specifies the type of tile package that will be created.
tpk
- Tiles are stored using Compact storage format. It is supported across the ArcGIS platform.tpkx
- Tiles are stored using CompactV2 storage format, which provides better performance on network shares and cloud store directories. This improved and simplified package structure type is supported by newer versions of ArcGIS products such as ArcGIS Online 7.1, ArcGIS Enterprise 10.7, and ArcGIS Runtime 100.5. This is the default.- Returns:
A path to download file is asynchronous is
False
. IfTrue
, 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)
The
find
method performs the map servicefind
operation.Parameter
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 be 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 from 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:
A dictionary
# USAGE EXAMPLE >>> from arcgis.layers import MapImageLayer >>> from arcgis.gis import GIS # connect to your GIS and get the web map item >>> gis = GIS(url, username, password) >>> map_image_item = gis.content.get("2aaddab96684405880d27f5261125061") >>> search_results = map_image_item.find(search_text = "Hurricane Data", contains = True, layers = "top", return_geometry = False, max_offset = 100, return_z = True, return_m = False, ) >>> type(search_results) <Dictionary>
- classmethod fromitem(item)
The
fromitem
method returns the layer at the specified index from a layerItem
object.Parameter
Description
item
Required Item. An item containing layers.
index
Optional int. The index of the layer amongst the item’s layers
- Returns:
The layer at the specified index.
# Usage Example >>> layer.fromitem(item="9311d21a9a2047d19c0faaebd6f2cca6", index=3)
- generate_kml(save_location, name, layers, options='composite')
The
generate_Kml
operation is performed on a map service resource. The result of this operation is a KML document wrapped in a KMZ file.Note
The document contains a network link to the KML Service endpoint with properties and parameters you specify.
Parameter
Description
save_location
Required string. Save folder.
name
Required string. 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:
A string to the file path
- identify(geometry, map_extent, image_display=None, 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.Note
Each identified result includes its
name
,layer ID
,layer name
,geometry
,geometry type
, and other attributes of that result as name-value pairs.Parameter
Description
geometry
Required
Geometry
or list. The geometry to identify on. The type of the geometry is specified by the geometryType parameter. The structure of the geometries is same as the structure of the JSON geometry objects returned by the API (See Geometry Objects). In addition to the JSON structures, for points and envelopes, you can specify the geometries with a simpler comma-separated syntax.geometry_type
Required string.The type of geometry specified by the geometry parameter. The geometry type could be a point, line, polygon, or an envelope. Values:
“Point” | “Multipoint” | “Polyline” | “Polygon” | “Envelope”
map_extent
Required string. The extent or bounding box of the map currently being viewed.
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.
time_value
Optional list. The time instant or the time extent of the features to be identified.
time_options
Optional dict. The time options per layer. Users can indicate whether or not the layer should use the time extent specified by the time parameter or not, whether to draw the layer features cumulatively or not and the time offsets for the layer.
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.
tolerance
Optional integer. The distance in screen pixels from the specified geometry within which the
identify
operation should be performed. The value for the tolerance is an integer.image_display
Optional string. The screen image display parameters (width, height, and DPI) of the map being currently viewed. The mapExtent and the image_display parameters are used by the server to determine the layers visible in the current extent. They are also used to calculate the distance on the map to search based on the tolerance in screen pixels.
Syntax:
<width>, <height>, <dpi>
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 be returned as is and dates will be returned as epoch values. The default is False.
return_field_name
Optional boolean. Default is False. 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. Transformations specified here are used to project features from layers within a map service to sr.
map_range_values
Optional list of dictionary(ies). Allows for the filtering features in the exported map from all layer that are within the specified range instant or extent.
layer_range_values
Optional Dictionary. Allows for the filtering of features for each individual layer that are within the specified range instant or extent.
layer_parameters
Optional list of dictionary(ies). Allows for the filtering of 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:
A dictionary
# USAGE EXAMPLE >>> from arcgis.layers import MapImageLayer >>> from arcgis.gis import GIS # connect to your GIS and get the web map item >>> gis = GIS(url, username, password) >>> map_image_item = gis.content.get("2aaddab96684405880d27f5261125061") >>> identified = map_image_item.identify(geometry = geom1, geometry_type = "Multipoint", image_display = "width", return_geometry =True, return_z = True, retrun_m = True, return_field_name = True, ) >>> type(identified) <Dictionary>
- property item_info
The
item_info
method retrieves the service’s item’s information.- Returns:
A dictionary
- property legend
The
legend
property 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.Note
The legend symbols include the base64 encoded imageData as well as a url that could be used to retrieve the image from the server.
- Returns:
Dictionary of legend information
- property manager
The
manager
property returns an instance ofMapImageLayerManager
class for ArcGIS Online andEnterpriseMapImageLayerManager
class for ArcGIS Enterprise which provides methods and properties for administering this service.
MapImageLayerManager
- class arcgis.layers.MapImageLayerManager(url, gis=None, map_img_lyr=None)
Bases:
_GISResource
The
MapImageLayerManager
class allows administration (if access permits) of ArcGIS Online Hosted Tile Layers or Cached Map Services. AMapImageLayer
offers access to the Map Server endpoints that allow you to edit the tile service, update tiles, refresh, and more.To use this manager off of the MapImageLayer Class, pass in a url ending with /MapServer when instantiating that class.
Note
Map Image Layers are created from Enterprise Services and their manager can be accessed through the EnterpriseMapImageLayerManager.
- 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.Parameter
Description
job_id
Required String. The job id to cancel.
- delete_tiles(levels, extent=None)
The
delete_tiles
method deletes tiles from the current cache.Parameter
Description
levels
Required string, The level to delete. Example, 0-5,10,11-20 or 1,2,3 or 0-5
extent
Optional dictionary, If specified, the tiles within this extent will be deleted or will be deleted based on the service’s full extent.
- Returns:
A dictionary
# USAGE EXAMPLE >>> from arcgis.layers import MapImageLayer >>> from arcgis.gis import GIS # connect to your GIS and get the web map item >>> gis = GIS(url, username, password) >>> map_image_layer = MapImageLayer("<url>", gis) >>> mil_manager = map_image_layer.manager >>> deleted_tiles = mil_manager.delete_tiles(levels = "11-20", extent = {"xmin":6224324.092137296, "ymin":487347.5253569535, "xmax":11473407.698535524, "ymax":4239488.369818687, "spatialReference":{"wkid":102100} } ) >>> type(deleted_tiles) <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)
The
edit_tile_service
operation updates a Tile Service’s properties.Parameter
Description
service_definition
Required String. Updates a service definition.
min_scale
Required float. Sets the services minimum scale for caching.
max_scale
Required float. Sets the services maximum scale for caching.
source_item_id
Required String. The Source Item ID is the GeoWarehouse Item ID of the map service
export_tiles_allowed
Required boolean.
exports_tiles_allowed
sets the value to let users export tilesmax_export_tile_count
Optional float.
max_export_tile_count
sets the maximum amount of tiles to be exported from a single call.Note
The default value is 100000.
# USAGE EXAMPLE >>> from arcgis.layers import MapImageLayer >>> from arcgis.gis import GIS # connect to your GIS and get the web map item >>> gis = GIS(url, username, password) >>> map_image_layer = MapImageLayer("<url>", gis) >>> mil_manager = map_image_layer.manager >>> mil_manager.edit_tile_service(service_definition = "updated service definition", min_scale = 50, max_scale = 100, source_item_id = "geowarehouse_item_id", export_tiles_allowed = True, max_Export_Tile_Count = 10000 )
- import_tiles(item, levels=None, extent=None, merge=False, replace=False)
The
import_tiles
method imports tiles from anItem
object.Before executing this operation, you will need to make certain the following prerequisites are met:
Upload the TPK you wish to merge with the existing service, take note of its item ID.
Make certain that the uploaded TPK, TPKX item’s tiling scheme matches with the service you wish to import into.
The source service LOD’s should include all the LOD’s that are part of the imported TPK item. For example, if the source service has tiles from levels 0 through 10, you can import tiles only within these levels and not above it.
- Returns:
A dictionary
# USAGE EXAMPLE >>> from arcgis.layers import MapImageLayer >>> from arcgis.gis import GIS # connect to your GIS and get the web map item >>> gis = GIS(url, username, password) >>> map_image_layer = MapImageLayer("<url>", gis) >>> mil_manager = map_image_layer.manager >>> imported_tiles = mil_manager.import_tiles(item="<item-id>", levels = "11-20", extent = {"xmin":6224324.092137296, "ymin":487347.5253569535, "xmax":11473407.698535524, "ymax":4239488.369818687, "spatialReference":{"wkid":102100} }, merge = True, replace = True ) >>> type(imported_tiles) <Dictionary>
- refresh()
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.Parameter
Description
job_id
required string, job to reprocess
code
required string, parameter used to re-run a given jobs with a specific error code:
ALL | ERROR | CANCELED
- Returns:
A boolean or dictionary
- update_tiles(levels=None, extent=None, merge=False, replace=False)
The
update_tiles
method 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
The
update_tiles
operation is for ArcGIS Online only.Parameter
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}
merge
Optional Boolean. Default is false and applicable to compact cache storage format. It controls whether the bundle files from the TPK file are merged with the one in the existing cached service. Otherwise, the bundle files are overwritten.
replace
Optional Boolean. Default is false, applicable to compact cache storage format and used when merge=true. It controls whether the new tiles will replace the existing ones when merging bundles.
- Returns:
Dictionary. If the product is not ArcGIS Online tile service, the result will be None.
# USAGE EXAMPLE >>> from arcgis.layers import MapImageLayer >>> from arcgis.gis import GIS # connect to your GIS and get the web map item >>> gis = GIS(url, username, password) >>> map_image_layer = MapImageLayer("<url>", gis) >>> mil_manager = map_image_layer.manager >>> update_tiles = mil_manager.update_tiles(levels = "11-20", extent = {"xmin":6224324.092137296, "ymin":487347.5253569535, "xmax":11473407.698535524, "ymax":4239488.369818687, "spatialReference":{"wkid":102100} } ) >>> type(update_tiles) <Dictionary>
EnterpriseMapImageLayerManager
- class arcgis.layers.EnterpriseMapImageLayerManager(url, gis=None, map_img_lyr=None)
Bases:
_GISResource
The
EnterpriseMapImageLayerManager
class allows administration (if access permits) of ArcGIS Enterprise Map Image Layers and Tile Layers. AMapImageLayer
offers access to layer content.Note
Url must be admin url such as:
https://services.myserver.com/arcgis/rest/admin/services/serviceName/MapServer/
- change_provider(provider)
Allows for the switching of the service provide and how it is hosted on the ArcGIS Server instance.
Provider parameter options:
ArcObjects means the service is running under the ArcMap runtime i.e. published from ArcMap
ArcObjects11: means the service is running under the ArcGIS Pro runtime i.e. published from ArcGIS Pro
DMaps: means the service is running in the shared instance pool (and thus running under the ArcGIS Pro provider runtime)
- Returns:
Boolean
- edit(service_dictionary)
To edit a service, you need to submit the complete JSON representation of the service, which includes the updates to the service properties. Editing a service causes the service to be restarted with updated properties.
Parameter
Description
service_dictionary
Required dict. The service JSON as a dictionary.
- Returns:
boolean
MapTable
- class arcgis.layers.MapTable(url, gis=None, container=None, dynamic_layer=None, time_filter=None)
Bases:
MapFeatureLayer
The
MapTable
class represents entity classes with uniform properties.Note
In addition to working with entities with
location
as features, theGIS
can also work with non-spatial entities as rows in tables.Working with tables is similar to working with a
MapFeatureLayer
, except that the rows (Feature
) in a table do not have a geometry, and tables ignore any geometry related operation.- classmethod fromitem(item, table_id=0)
The
fromitem
method creates aMapTable
from a GISItem
.Parameter
Description
item
Required
Item
object. The type of item should be aMapImageService
object.layer_id
Optional integer. The id of the layer in the Map Service’s Layer. The default is 0.
- Returns:
A
MapTable
object
# USAGE EXAMPLE >>> from arcgis.layers import MapImageLayer, MapTable >>> from arcgis.gis import GIS # connect to your GIS and get the web map item >>> gis = GIS(url, username, password) >>> map_image_item = gis.content.get("2aaddab96684405880d27f5261125061") >>> map_table = MapFeatureLayer.fromitem(item = map_image_item, layer_id = 2) >>> print(f"{map_table.properties.name:30}{type(map_table)}") <State Boundaries <class 'arcgis.layers.MapTable'>>
- query(where='1=1', out_fields='*', time_filter=None, return_count_only=False, return_ids_only=False, return_distinct_values=False, group_by_fields_for_statistics=None, statistic_filter=None, result_offset=None, result_record_count=None, object_ids=None, gdb_version=None, order_by_fields=None, out_statistics=None, return_all_records=True, historic_moment=None, sql_format=None, return_exceeded_limit_features=None, as_df=False, range_values=None, parameter_values=None, **kwargs)
The
query
method queries a Table Layer based on a set of criteria from a sql statement.Parameter
Description
where
Optional string. The default is 1=1. The selection sql statement.
out_fields
Optional List of field names to return. Field names can be specified either as a List of field names or as a comma separated string. The default is “*”, which returns all the fields.
object_ids
Optional string. The object IDs of this layer or table to be queried. The object ID values should be a comma-separated string.
time_filter
Optional list. The format is of [<startTime>, <endTime>] using _dt.datetime.date, _dt.datetime._dt.datetime or timestamp in milliseconds.
>>> time_filter=[<startTime>, <endTime>]
Specified as
_dt.datetime.date
,_dt.datetime._dt.datetime
ortimestamp
in milliseconds.>>> import _dt.datetime as dt >>> time_filter = [dt._dt.datetime(2022, 1, 1), dt.dateime(2022, 1, 12)]
gdb_version
Optional string. The geodatabase version to query. This parameter applies only if the isDataVersioned property of the layer is true. If this is not specified, the query will apply to the published map’s version.
return_geometry
Optional boolean. If True, geometry is returned with the query. Default is True.
return_distinct_values
Optional boolean. If True, it returns distinct values based on the fields specified in out_fields. This parameter applies only if the supportsAdvancedQueries property of the layer is true.
return_ids_only
Optional boolean. Default is False. If True, the response only includes an array of object IDs. Otherwise, the response is a
FeatureSet
.return_count_only
Optional boolean. If True, the response only includes the count (number of features/records) that would be returned by a query. Otherwise, the response is a
FeatureSet
. The default is False. This option supersedes the return_ids_only parameter. If return_count_only = True, the response will return both the count and the extent.order_by_fields
Optional string. One or more field names by which to order the results. Use
ASC
orDESC
for ascending or descending, respectively, following every field to be ordered:>>> order_by_fields = "STATE_NAME ASC, RACE DESC, GENDER ASC"
group_by_fields_for_statistics
Optional string. One or more field names on which to group results for calculating the statistics.
>>> group_by_fields_for_statiscits = "STATE_NAME, GENDER"
out_statistics
Optional string. The definitions for one or more field-based statistics to be calculated.
- Syntax:
>>> out_statistics = [ { "statisticType": "<count | sum | min | max | avg | stddev | var>", "onStatisticField": "Field1", "outStatisticFieldName": "Out_Field_Name1" },{ "statisticType": "<count | sum | min | max | avg | stddev | var>", "onStatisticField": "Field2", "outStatisticFieldName": "Out_Field_Name2" } ]
result_offset
Optional integer. This option can be used for fetching query results by skipping the specified number of records and starting from the next record (that is, result_offset + ith). This option is ignored if return_all_records is True (i.e. by default).
result_record_count
Optional integer. This option can be used for fetching query results up to the result_record_count specified. When result_offset is specified but this parameter is not, the map service defaults it to max_record_count. The maximum value for this parameter is the value of the layer’s maxRecordCount property. This option is ignored if return_all_records is True (i.e. by default).
return_all_records
Optional boolean. When True, the query operation will call the service until all records that satisfy the where_clause are returned. Note: result_offset and result_record_count will be ignored if return_all_records is True. Also, if return_count_only, return_ids_only, or return_extent_only are True, this parameter will be ignored.
historic_moment
Optional integer. The historic moment to query. This parameter applies only if the layer is archiving enabled and the supportsQueryWithHistoricMoment property is set to true. This property is provided in the layer resource.
Note
See Query (Feature Service/Layer) for full explanation of layer properties. Use
properties
to examine layer properties.If historic_moment is not specified, the query will apply to the current features.
sql_format
Optional string. The sql_format parameter can be either standard SQL92 or it can use the native SQL of the underlying datastore. The default is none which means the sql_format depends on the useStandardizedQuery parameter. Values:
none
|standard
|native
return_exceeded_limit_features
Optional boolean. Optional parameter which is true by default. When set to true, features are returned even when the results include the exceededTransferLimit: true property.
When set to false and querying with resultType = ‘tile’, features are not returned when the results include exceededTransferLimit: True. This allows a client to find the resolution in which the transfer limit is no longer exceeded without making multiple calls.
as_df
Optional boolean. If True, the results are returned as a DataFrame instead of a
FeatureSet
.range_values
Optional List. Allows you to filter features from the layer that are within the specified range instant or extent.
- Syntax:
>>> range_values = [ { "name": "range name", "value": <value> or [ <value1>, <value2> ] }, { "name": "range name 2", "value": <value> or [ <value3>, <value4>] } } ]
Note
None is allowed in value-range case – that means infinity
# all features with values <= 1500 >>> range_values = {"name" : "range name", "value :[None, 1500]} # all features with values >= 1000 >>> range_values = {"name" : "range name", "value" : [1000, None]}
parameter_values
Optional Dict. Allows you to filter the features layers 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.
When parameterInfo allows multiple values, you must pass them in an array.
Note: Check parameterInfos at the layer
properties
for the available parameterized filters, their default values and expected data type.kwargs
Optional dict. Optional parameters that can be passed to the Query function. This will allow users to pass additional parameters not explicitly implemented on the function. A complete list of possible parameters is documented at Query (Map Service/Layer)
- Returns:
A
FeatureSet
or Panda’s DataFrame containing theFeature
objects matching the query, unless another return type is specified, such ascount
# USAGE EXAMPLE >>> from arcgis.layers import MapImageLayer, MapFeatureLayer >>> from arcgis.gis import GIS # connect to your GIS and get the web map item >>> gis = GIS(url, username, password) >>> map_image_item = gis.content.get("2aaddab96684405880d27f5261125061") >>> map_feature_layer = MapFeatureLayer.fromitem(item = map_image_item, layer_id = 2) >>> query_count = map_feature_layer.query(where "1=1", text = "Hurricane Data", units = "esriSRUnit_Meter", return_count_only = True, out_statistics = [ { "statisticType": "count", "onStatisticField": "Field1", "outStatisticFieldName": "Out_Field_Name1" }, { "statisticType": "avg", "onStatisticField": "Field2", "outStatisticFieldName": "Out_Field_Name2" } ], range_values= [ { "name": "range name", "value": [None, 1500] }, { "name": "range name 2", "value":[1000, None] } } ] ) >>> query_count <149>
VectorTileLayer
- class arcgis.layers.VectorTileLayer(url, gis)
Bases:
Layer
A Vector Tile Layer is a type of data layer used to access and display tiled data and its corresponding styles. This is stored as an item in ArcGIS and is used to access a vector tile service. Layer data include its name, description, and any overriding style definition.
- export_tiles(levels=None, export_extent=None, polygon=None, create_item=False)
Export vector tile layer
Parameter
Description
levels
Optional string.Specifies the tiled service levels to export. The values should correspond to Level IDs. The values can be comma-separated values or a range of values. Ensure that the tiles are present at each specified level.
# Example: # Comma-separated values >>> levels=1,2,3,4,5,6,7,8,9 //Range values >>> levels=1-4, 7-9
export_extent
Optional dictionary of the extent (bounding box) of the vector tile package to be exported. The extent should be within the specified spatial reference. The default value is the full extent of the tiled map service.
# Example: >>> export_extent = { "xmin": -109.55, "ymin" : 25.76, "xmax": -86.39, "ymax" : 49.94, "spatialReference": {"wkid": 4326} }
polygon
Optional dictionary. Introduced at 10.7. A JSON representation of a polygon, containing an array of rings and a spatialReference.
# Example: polygon = { "rings": [ [[6453,16815],[10653,16423], [14549,5204],[-7003,6939], [6453,16815]],[[914,7992], [3140,11429],[1510,10525], [914,7992]] ], "spatialReference": {"wkid": 54004} }
create_item
Optional boolean. Indicated whether an item will be created from the export (True) or a path to a downloaded file (False). Default is False. ArcGIS Online Only.
- Returns:
A list of exported item dictionaries or a single path
- classmethod fromitem(item)
The
fromitem
method returns the layer at the specified index from a layerItem
object.Parameter
Description
item
Required Item. An item containing layers.
index
Optional int. The index of the layer amongst the item’s layers
- Returns:
The layer at the specified index.
# Usage Example >>> layer.fromitem(item="9311d21a9a2047d19c0faaebd6f2cca6", index=3)
- property info
The
info
property retrieves the relative paths to a list of resource files.- Returns:
A list of relative paths
- property manager
The
manager
property returns an instance ofVectorTileLayerManager
class orEnterpriseVectorTileLayerManager
class which provides methods and properties for administering this service.
- property styles
The styles property returns styles for vector tiles in Mapbox GL Style specification version 8. The response for this styles resource includes the sprite and glyphs properties, with a relative path to the Vector Tile Sprite and Vector Tile Font resources. It also includes the version property, which represents the version of the style specification.
- tile_fonts(fontstack, stack_range)
The
tile_fonts
method retrieves glyphs in protocol buffer format.Parameter
Description
fontstack
Required string.
Note
The template url for this font resource is represented in the Vector Tile Style resource.
stack_range
Required string that depict a range. Ex: “0-255”
- Returns:
Glyphs in PBF format
- property tile_map
The tile_map property describes a quadtree of tiles and can be used to avoid requesting tiles that don’t exist in the server. Each node of the tree has an associated tile. The root node (lod 0) covers the entire extent of the data. Children are identified by their position with NW, NE, SW, and SE. Tiles are identified by lod/h/v, where h and v are indexes on a 2^lod by 2^lod grid . These values are derived from the position in the tree. The tree has a variable depth. A node doesn’t have children if the complexity of the data in the associated tile is below a threshold. This threshold is based on a combination of number of features, attributes, and vertices.
- tile_sprite(out_format='sprite.json')
The
tile_sprite
resource retrieves sprite images and metadata.Parameter
Description
out_format
Optional string. Default is “sprite.json”.
Values:
sprite.json
|sprite.png
|sprite@2x.png
- Returns:
Sprite image and metadata.
- vector_tile(level, row, column)
The
vector_tile
method represents a single vector tile for the map.Note
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.
Parameter
Description
level
Required string. A level number as a string.
row
Required string. Number of the row that the tile belongs to.
column
Required string. Number of the column that tile belongs to.
- Returns:
Bytes in PBF format
VectorTileLayerManager
- class arcgis.layers.VectorTileLayerManager(url, gis=None, vect_tile_lyr=None)
Bases:
_GISResource
The
VectorTileLayerManager
class allows administration (if access permits) of ArcGIS Online Hosted Vector Tile Layers. A Hosted Vector Tile Service is published through a Feature Layer and these methods can only be applied to such Vector Tile Services. AVectorTileLayer
offers access to layer content.Note
Url must be admin url such as:
https://services.myserver.com/arcgis/rest/admin/services/serviceName/VectorTileServer/
- cancel_job(job_id)
The cancel 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.
- delete_job(job_id)
This operation deletes the specified asynchronous job being run by the geoprocessing service. If the current status of the job is SUBMITTED or EXECUTING, it will cancel the job. Regardless of status, it will remove all information about the job from the system. To cancel a job in progress without removing information, use the Cancel Job operation.
- delete_tiles()
The
delete_tiles
method deletes tiles from the current cache.Note
The
delete_tiles
operation is for ArcGIS Online only and can only be used for a Vector Tile Layer published from a service directory.- Returns:
A dictionary
# USAGE EXAMPLE >>> from arcgis.layers import VectorTileLayer >>> from arcgis.gis import GIS # connect to your GIS >>> gis = GIS(url, username, password) >>> vector_layer_item = gis.content.get('abcd_item-id') >>> vector_tile_layer = VectorTileLayer.fromitem(vector_layer_item) >>> vtl_manager = vector_tile_layer.manager >>> deleted_tiles = vtl_manager.delete_tiles() >>> type(deleted_tiles)
- edit_tile_service(source_item_id=None, export_tiles_allowed=None, min_scale=None, max_scale=None, max_export_tile_count=None, layers=None, cache_max_age=None, max_zoom=None)
The edit operation enables editing many parameters in the service definition as well as the source_item_id which can be found by looking at the Vector Tile Layer’s related items.
Parameter
Description
source_item_id
Optional String. The Source Item ID is the GeoWarehouse Item ID of the tile service.
export_tiles_allowed
Optional boolean.
exports_tiles_allowed
sets the value to let users export tilesmin_scale
Optional float. Sets the services minimum scale for caching. At the moment this parameter can only be set if the Vector Tile Layer was published through a service directory.
max_scale
Optional float. Sets the services maximum scale for caching. At the moment this parameter can only be set if the Vector Tile Layer was published through a service directory.
max_export_tile_count
Optional int.
max_export_tile_count
sets the maximum amount of tiles to be exported from a single call.layers
Optional list of dictionaries. Each dict representing a layer.
Syntax Example:
layers = [{“name”: “Layer Name”,“id”: 1159321,“layerId”: 0,“tableName”: “tableName”,“type”: “Feature Layer”,“xssTrustedFields”: “”}]cache_max_age
Optional int. The maximum cache age. At the moment this parameter can only be set if the Vector Tile Layer was published through a feature service.
max_zoom
Optional int. The maximum zoom level. At the moment this parameter can only be set if the Vector Tile Layer was published through a feature service.
# USAGE EXAMPLE >>> from arcgis.layers import VectorTileLayer >>> from arcgis.gis import GIS # connect to your GIS and get the tile layer item >>> gis = GIS(url, username, password) >>> vector_layer_item = gis.content.get('abcd_item-id') >>> source_item_id = vector_tile_item.related_items(rel_type="Service2Data", direction="forward")[0]["id"] >>> vector_tile_layer = VectorTileLayer.fromitem(vector_layer_item) >>> vtl_manager = vector_tile_layer.manager >>> vtl_manager.edit_tile_service( min_scale = 50, max_scale = 100, source_item_id = source_item_id, export_tiles_allowed = True, max_Export_Tile_Count = 10000 )
- job_statistics(job_id)
The tile service job summary (jobs) resource represents a summary of all jobs associated with a vector tile service. Each job contains a jobid that corresponds to the specific jobid run and redirects you to the Job Statistics page.
- jobs()
The tile service job summary (jobs) resource represents a summary of all jobs associated with a vector tile service. Each job contains a jobid that corresponds to the specific jobid run and redirects you to the Job Statistics page.
- rebuild_cache()
The rebuild_cache operation update the vector tile layer cache to reflect any changes made to the feature layer used to publish this vector tile layer. The results of the operation is a response indicating success, which redirects you to the Job Statistics page, or failure.
- rerun_job(code, job_id)
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.Parameter
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:
A boolean or dictionary
- status()
The status operation returns a dictionary indicating whether a service is started (available) or stopped.
- swap(target_service_name)
The swap operation replaces the current service cache with an existing one.
Note
The
swap
operation is for ArcGIS Online only and can only be used for a Vector Tile Layer published from a service directory.Parameter
Description
target_service_name
Required string. Name of service you want to swap with.
- Returns:
Dictionary indicating success or error
- update_tiles(merge_bundle=False)
The update_tiles operation supports updating the cooking extent and cache levels in a Hosted Vector Tile Service. The results of the operation is a response indicating success and a url to the Job Statistics page, or failure.
It is recommended to use the rebuild_cache method when your layer has been published through a Feature Layer since edits require regeneration of the tiles.
Parameter
Description
merge_bundle
Optional bool. Default is False. This parameter will only be set if the Vector Tile Layer has been published through a service directory.
- Returns:
Dictionary. If the product is not ArcGIS Online tile service, the result will be None.
# USAGE EXAMPLE >>> from arcgis.layers import VectorTileLayer >>> from arcgis.gis import GIS # connect to your GIS and get the web map item >>> gis = GIS(url, username, password) >>> vector_layer_item = gis.content.get('abcd_item-id') >>> vector_tile_layer = VectorTileLayer.fromitem(vector_layer_item) >>> vtl_manager = vector_tile_layer.manager >>> update_tiles = vtl_manager.update_tiles() >>> type(update_tiles) <Dictionary>
EnterpriseVectorTileLayerManager
- class arcgis.layers.EnterpriseVectorTileLayerManager(url, gis=None, vect_tile_lyr=None)
Bases:
_GISResource
The
EnterpriseVectorTileLayerManager
class allows administration (if access permits) of ArcGIS Enterprise hosted vector tile layers. A Hosted Vector Tile Service is published through a Feature Layer and these methods can only be applied to such Vector Tile Services. AVectorTileLayer
offers access to layer content.Note
Url must be admin url such as:
https://services.myserver.com/arcgis/server/admin/services/serviceName.VectorTileServer/
- change_provider(provider)
The changeProvider operation updates an individual service to use either a dedicated or a shared instance type. When a qualified service is published, the service is automatically set to use shared instances.
When using this operation, services may populate other provider types as values for the provider parameter, such as ArcObjects and SDS. While these are valid provider types, this operation does not support changing the provider of such services to either ArcObjects11 or DMaps. Services with ArcObjects or SDS as their provider cannot change their instance type.
Parameter
Description
provider
Optional String. Specifies the service instance as either a shared (“DMaps”) or dedicated (“ArcObjects11”) instance type. These values are case sensitive.
- Returns:
Boolean
- delete()
This operation deletes an individual service, stopping the service and removing all associated resources and configurations.
- edit(service_dictionary)
This operation edits the properties of a service. To edit a service, you need to submit the complete JSON representation of the service, which includes the updates to the service properties. Editing a service can cause the service to be restarted with updated properties.
The JSON representation of a service contains the following four sections:
Service description properties—Common properties that are shared by all services. These properties typically identify a specific service.
Service framework properties—Properties targeted toward the framework that hosts the GIS service. They define the life cycle and load balancing of the service.
Service type properties—Properties targeted toward the core service type as seen by the server administrator. Since these properties are associated with a server object, they vary across the service types.
Extension properties—Represent the extensions that are enabled on the service.
Note
The JSON is submitted to the operation URL as a value of the parameter service. You can leave out the serviceName and type parameters in the JSON representation. Any other properties that are left out are not persisted by the server.
Parameter
Description
service_dictionary
Required dict. The JSON representation of the service and the properties that have been updated or added.
Example:
{“serviceName”: “RI_Fed2019_WM”,“type”: “VectorTileServer”,“description”: “”,“capabilities”: “TilesOnly,Tilemap”,“extensions”: [],“frameworkProperties”: {},“datasets”: []}- Returns:
boolean
- rebuild_cache(min_scale=None, max_scale=None)
The rebuild_cache operation updates the vector tile layer cache to reflect any changes made. The results of the operation is the url to the vector tile service once it is done rebuilding.
Parameter
Description
min_scale
Optional Float. Represents the minimum scale of the tiles. If nothing is provided, default value is used.
max_scale
Optional Float. Represents the maximum scale of the tiles. If nothing is provided, default value is used.
Working with OGC layers
CSVLayer
- class arcgis.layers.CSVLayer(url_or_item, gis=None, **kwargs)
Bases:
BaseOpenData
Represents a CSV File Hosted on a Server.
Parameter
Description
url_or_item
Required String or Item. The web address or
Item
to the CSV resource.gis
Optional
GIS
. The GIS used to reference the service. Theactive_gis
is used if not specified.copyright
Optional String. Describes limitations and usage of the data.
delimiter
Optional String. The separator value. This can be the following:
, (comma), ‘ ‘ (space), | (pipe), r (tab), or ; (semicolon).
fields
Optional List. An array of dictionaries containing the field information.
opacity
Optional Float. This value can range between 1 and 0, where 0 is 100 percent transparent and 1 is completely opaque.
scale
Optional Tuple. The min/max scale of the layer where the positions are: (min, max) as float values.
sql_expression
Optional String. Optional query string to apply to the layer when displayed on the widget or web map.
title
Optional String. The title of the layer used to identify it in places such as the Legend and Layer List widgets.
- property latitude
The latitude field name. If not specified, the class will look for following field names in the CSV source:
“lat”, “latitude”, “y”, “ycenter”, “latitude83”, “latdecdeg”, “POINT-Y”
- property longitude
The longitude field name. If not specified, the CSVLayer will look for following field names in the CSV source:
“lon”, “lng”,”long”, “longitude”, “x”, “xcenter”, “longitude83”, “longdecdeg”, “POINT-X”
- property opacity
Get/Set the opacity value.
Parameter
Description
value
Required float. Value can range between 1 and 0, where 0 is 100 percent transparent and 1 is completely opaque.
- Returns:
Float
- property renderer
Get/Set the Renderer of the CSV Layer
- Returns:
A
dict
like object used to update and alter JSON
- property scale
Gets/Sets the Min/Max Scale for the layer
Parameter
Description
value
Required tuple. (Min_value, Max_value)
- Returns:
A tuple (min, max)
- property sql_expression
The SQL where clause used to filter features on the client. Only the features that satisfy the definition expression are displayed in the widget. Setting a definition expression is useful when the dataset is large and you don’t want to bring all features to the client for analysis. The sql_expressions may be set when a layer is constructed prior to it loading in the view or after it has been loaded into the class.
- Returns:
String
GeoJSONLayer
- class arcgis.layers.GeoJSONLayer(url=None, data=None, **kwargs)
Bases:
BaseOGC
The GeoJSONLayer class is used to create a layer based on GeoJSON. GeoJSON is a format for encoding a variety of geographic data structures. The GeoJSON data must comply with the RFC 7946 specification which states that the coordinates are in spatial reference: WGS84 (wkid 4326).
Parameter
Description
url
Optional String. The web location of the GeoJSON file.
data
Optional String or Dict. A path to a GeoJSON file, the GeoJSON data as a string, or the GeoJSON data as a dictionary.
copyright
Optional String. Describes limitations and usage of the data.
opacity
Optional Float. This value can range between 1 and 0, where 0 is 100 percent transparent and 1 is completely opaque.
renderer
Optional Dictionary. A custom set of symbology for the given geojson dataset.
scale
Optional Tuple. The min/max scale of the layer where the positions are: (min, max) as float values.
title
Optional String. The title of the layer used to identify it in places such as the Legend and Layer List widgets.
- property opacity
Get/Set the opacity value.
Parameter
Description
value
Required float. Value can range between 1 and 0, where 0 is 100 percent transparent and 1 is completely opaque.
- Returns:
Float
- property scale
Gets/Sets the Min/Max Scale for the layer
Parameter
Description
value
Required tuple. (Min_value, Max_value)
- Returns:
A tuple (min, max)
GeoRSSLayer
- class arcgis.layers.GeoRSSLayer(url, **kwargs)
Bases:
BaseOGC
The GeoRSSLayer class is used to create a layer based on GeoRSS. GeoRSS is a way to add geographic information to an RSS feed. The GeoRSSLayer supports both GeoRSS-Simple and GeoRSS GML encodings, and multiple geometry types.
It exports custom RSS tags as additional attribute fields in the form of simple strings or an array of JSON objects.
Parameter
Description
url
Required String. The URL of the GeoRSS sevice.
copyright
Optional String. Describes limitations and usage of the data.
line_symbol
Optional Dict. The symbol for the polyline data in the GeoRSS.
opacity
Optional Float. This value can range between 1 and 0, where 0 is 100 percent transparent and 1 is completely opaque.
point_symbol
Optional Dict. The symbol for the point data in the GeoRSS.
polygon_symbol
Optional Dict. The symbol for the polygon data in the GeoRSS.
title
Optional String. The title of the layer used to identify it in places such as the Legend and LayerList widgets.
scale
Optional Tuple. The min/max scale of the layer where the positions are: (min, max) as float values.
- property line_symbol
Gets/Sets the Line Symbol for Polyline Geometries
- Returns:
InsensitiveDict
: A case-insensitivedict
like object used to update and alter JSON A variants of a case-less dictionary that allows for dot and bracket notation.
- property opacity
Get/Set the opacity value.
Parameter
Description
value
Required float. Value can range between 1 and 0, where 0 is 100 percent transparent and 1 is completely opaque.
- Returns:
Float
- property point_symbol
Gets/Sets the Point Symbol for Point Geometries
- Returns:
A
dict
object used to update and alter JSON
- property polygon_symbol
Gets/Sets the Polygon Symbol for Polygon Geometries
- Returns:
InsensitiveDict
: A case-insensitivedict
like object used to update and alter JSON A variants of a case-less dictionary that allows for dot and bracket notation.
OGCFeatureService
- class arcgis.layers.OGCFeatureService(url, gis=None)
Bases:
object
Represents the Hosted OGC Feature Server
Parameter
Description
url
Required String. The web address endpoint.
gis
Optional
GIS
. The connection object.
OGCCollection
- class arcgis.layers.OGCCollection(url, gis=None)
Bases:
object
Represents a single OGC dataset
Parameter
Description
url
Required String. The web address endpoint.
gis
Optional
GIS
. The connection object.- get(feature_id)
Gets an individual feature on the service. Needs to correspond to an id of the feature.
- Returns:
Dict[str, Any]
- query(query=None, limit=10000, bbox=None, bbox_sr=None, time_filter=None, return_all=False, **kwargs)
Queries the
OGCFeatureService
Layer and returns back the information as a Spatially Enabled DataFrame.Parameter
Description
query
Optional String. A SQL based query applied to the service.
limit
Optional Integer. The number of records to limit to. The default is 10,000.
bbox
Optional List[float]. The bounding box to limit search in.
bbox_sr
Optional Integer. The coordinate reference system as a WKID.
time_filter
Optional String. The dates to filter time by.
- Returns:
Union[Dict[str, Any], pd.DataFrame]
WMSLayer
- class arcgis.layers.WMSLayer(url, version='1.3.0', gis=None, **kwargs)
Bases:
BaseOGC
Represents a Web Map Service, which is an OGC web service endpoint.
Parameter
Description
url
Required string. The administration URL for the ArcGIS Server.
version
Optional String. The version number of the WMS service. The default is 1.3.0.
gis
Optional
GIS
. The GIS used to reference the service by. The arcgis.env.active_gis is used if not specified.copyright
Optional String. Describes limitations and usage of the data.
scale
Optional Tuple. The min/max scale of the layer where the positions are: (min, max) as float values.
opacity
Optional Float. This value can range between 1 and 0, where 0 is 100 percent transparent and 1 is completely opaque.
title
Optional String. The title of the layer used to identify it in places such as the Legend and Layer List widgets.
- property opacity
Get/Set the opacity value.
Parameter
Description
value
Required float. Value can range between 1 and 0, where 0 is 100 percent transparent and 1 is completely opaque.
- Returns:
Float
WMTSLayer
- class arcgis.layers.WMTSLayer(url, version='1.0.0', gis=None, **kwargs)
Bases:
BaseOGC
Represents a Web Map Tile Service, which is an OGC web service endpoint.
Parameter
Description
url
Required string. The web address of the endpoint.
version
Optional String. The version number of the WMTS service. The default is 1.0.0
gis
Optional
GIS
. The GIS used to reference the service by. The arcgis.env.active_gis is used if not specified.copyright
Optional String. Describes limitations and usage of the data.
opacity
Optional Float. This value can range between 1 and 0, where 0 is 100 percent transparent and 1 is completely opaque.
scale
Optional Tuple. The min/max scale of the layer where the positions are: (min, max) as float values.
title
Optional String. The title of the layer used to identify it in places such as the Legend and Layer List widgets.
- property opacity
Get/Set the opacity value.
Parameter
Description
value
Required float. Value can range between 1 and 0, where 0 is 100 percent transparent and 1 is completely opaque.
- Returns:
Float