arcgis.layers module
The arcgis.layers module provides components for visualizing GIS data and analysis.This module also includes mapping layers like MapImageLayer, SceneLayer and VectorTileLayer.
Service
- classarcgis.layers._service_factory.Service(url_or_item:Item|str=None,server=None,initialize=False,parent_url=None)
Bases:
object
TheService class allows users to pass aurl string or an
Item
, along with an optionalGIS
connection or specificServer
object to returnan instance of the specific ArcGIS API for Python object the servicerepresents.Parameter
Description
url_or_item
Required String. Internet endpoint for the serviceto initialize as a Python object.
server
- Returns:
An object representing the service type of the input value.
# Usage Example: Directly from a url>>>fromarcgis.gisimportGIS>>>fromarcgis.layersimportService>>>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<FeatureLayerCollectionurl:"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.typeVectorTileService>>>vts=Service(url_or_item=org_item)>>>vts<VectorTileLayerurl:"https://tiles.arcgis.com/tiles/<org_id>/arcgis/rest/services/Custom_Basemap_SXT/VectorTileServer">
BasemapServices
- classarcgis.layers.BasemapServices(gis=None)
Bases:
object
The basemap styles service is a ready-to-use location service that serves vectorand image tiles that represent geographic features around the world. It includesstyles that represent topographic features, road networks, footpaths, buildingfootprints, water features, administrative boundaries, and satellite imagery.The styles are returned as JSON based on the Mapbox Style Specification or the ArcGISWeb Map Specification. The service also supports displaying localized language placelabels, 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 basemapproperty to apply the style to the map.
- propertylanguages
Returns a list of supported languages for the basemap styles.To see which languages are supported by each service look at the documentationfound here:https://developers.arcgis.com/rest/basemap-styles/
- propertyplaces
Returns a list of supported places for the basemap styles.To see which services support which places look at the documentationfound here:https://developers.arcgis.com/rest/basemap-styles/
- propertyworldviews
Returns a list of supported worldviews for the basemap styles.To see which services support which worldviews look at the documentationfound here:https://developers.arcgis.com/rest/basemap-styles/
BasemapService
Working with 3D Maps
SceneLayer
- classarcgis.layers.SceneLayer(url,gis=None,parent_url=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 andintegrated mesh layers.
Parameter
Description
url
Required string, specify the url ending in /SceneServer/
gis
Optional
GIS
object. If not specified, the active GIS connection isused.# USAGE EXAMPLE 1: Instantiating a SceneLayer objectfromarcgis.layersimportSceneLayers_layer=SceneLayer(url='https://your_portal.com/arcgis/rest/services/service_name/SceneServer/')type(s_layer)>>arcgis.layers.PointCloudLayerprint(s_layer.properties.layers[0].name)>>'your layer name'
SceneLayerManager
- classarcgis.layers.SceneLayerManager(url:str,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:str)→dict|None
The
cancel_job
operation supports cancelling a job while updatetiles is running from a hosted feature service. The result of thisoperation is a response indicating success or failure with errorcode and description.Parameter
Description
job_id
Required String. The job id to cancel.
- edit(item:str|Item)→dict|None
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 fileswhich are then merged into an existing cache service.- Returns:
A dictionary
- import_package(item:str|Item)→dict|None
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 fileswhich are then merged into an existing cache service.- Returns:
A dictionary
- jobs()→dict|None
The tile service job summary (jobs) resource represents asummary of all jobs associated with a vector tile service.Each job contains a jobid that corresponds to the specificjobid run and redirects you to the Job Statistics page.
- rebuild_cache(layers:int|list[int])→dict|None
The rebuild_cache operation update the scene layer cache to reflectany changes made to the feature layer used to publish this scene layer.The results of the operation is a response indicating success, whichredirects you to the Job Statistics page, or failure.
Parameter
Description
layers
Required int or list of int. Comma separated values indicatingthe id of the layers to rebuild in the cache.
Ex: [0,1,2]
- refresh()→dict|None
The
refresh
operation refreshes a service, which clears the webserver cache for the service.
- rerun_job(job_id:str,code:str)→dict|None
The
rerun_job
operation supports re-running a canceled job from ahosted map service. The result of this operation is a responseindicating success or failure with error code and description.Parameter
Description
code
Required string, parameter used to re-run a givenjobs with a specific errorcode:
ALL|ERROR|CANCELED
job_id
Required string, job to reprocess
- Returns:
A boolean or dictionary
- swap(target_service_name:str)→dict|None
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()→dict|None
The
update
method starts update generation for ArcGIS Online. It updatesthe underlying source dataset for the service, essentially refreshing theunderlying package data.- Returns:
Dictionary.
- update_attribute(layers:int|list[int])→dict|None
Update atrribute is a “light rebuild” where attributes ofthe layers selected are updated and can be used for change tracking.The results of the operation is a response indicating success, whichredirects you to the Job Statistics page, or failure.
Parameter
Description
layers
Required int or list of int. Comma separated values indicatingthe id of the layers to update in the cache.
Ex: [0,1,2]
- update_cache(layers:int|list[int])→dict|None
Update Cache is a “light rebuild” where attributes and geometries ofthe layers selected are updated and can be used for change tracking onthe feature layer to only update nodes with dirty tiles.The results of the operation is a response indicating success, whichredirects you to the Job Statistics page, or failure.
Parameter
Description
layers
Required int or list of int. Comma separated values indicatingthe id of the layers to update in the cache.
Ex: [0,1,2]
EnterpriseSceneLayerManager
- classarcgis.layers.EnterpriseSceneLayerManager(url:str,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:str)
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:dict)
To edit a service, you need to submit the complete JSONrepresentation of the service, which includes the updates to theservice properties. Editing a service causes the service to berestarted with updated properties.
- Returns:
boolean
- rebuild_cache(layer:list[int]|None=None,extent:dict|None=None,area_of_interest:dict|None=None)→str
The rebuild_cache operation update the scene layer cache to reflectany 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 isdone 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 areaof 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:list[int]|None=None,extent:dict|None=None,area_of_interest:dict|None=None)→str
Update atrribute is a “light rebuild” where attributes ofthe 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 isdone 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 areaof 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:list[int]|None=None,extent:dict|None=None,area_of_interest:dict|None=None)→str
Update Cache is a “light rebuild” where attributes and geometries ofthe layers selected are updated and can be used for change tracking onthe feature layer to only update nodes with dirty tiles,.The results of the operation is the url to the scene service once it isdone 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 areaof 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
- classarcgis.layers.BuildingLayer(url:str,gis=None,parent_url=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 isused.# USAGE EXAMPLE 1: Instantiating a SceneLayer objectfromarcgis.layersimportSceneLayers_layer=SceneLayer(url='https://your_portal.com/arcgis/rest/services/service_name/SceneServer/')type(s_layer)>>arcgis.layers.BuildingLayerprint(s_layer.properties.layers[0].name)>>'your layer name'
- propertymanager:SceneLayerManager|EnterpriseSceneLayerManager
The
manager
property returns an instance ofSceneLayerManager
classorEnterpriseSceneLayerManager
classwhich provides methods and properties for administering this service.
IntegratedMeshLayer
- classarcgis.layers.IntegratedMeshLayer(url:str,gis=None,parent_url=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 isused.# USAGE EXAMPLE 1: Instantiating a SceneLayer objectfromarcgis.layersimportSceneLayers_layer=SceneLayer(url='https://your_portal.com/arcgis/rest/services/service_name/SceneServer/')type(s_layer)>>arcgis.layers.Point3DLayerprint(s_layer.properties.layers[0].name)>>'your layer name'
- propertymanager:SceneLayerManager|EnterpriseSceneLayerManager
The
manager
property returns an instance ofSceneLayerManager
classorEnterpriseSceneLayerManager
classwhich provides methods and properties for administering this service.
Tiles3DLayer
- classarcgis.layers.Tiles3DLayer(url:str,gis=None,parent_url=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 isused.
Object3DLayer
- classarcgis.layers.Object3DLayer(url:str,gis=None,parent_url=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 isused.# USAGE EXAMPLE 1: Instantiating a SceneLayer objectfromarcgis.layersimportSceneLayers_layer=SceneLayer(url='https://your_portal.com/arcgis/rest/services/service_name/SceneServer/')type(s_layer)>>arcgis.layers.Point3DLayerprint(s_layer.properties.layers[0].name)>>'your layer name'
- propertymanager:SceneLayerManager|EnterpriseSceneLayerManager
The
manager
property returns an instance ofSceneLayerManager
classorEnterpriseSceneLayerManager
classwhich provides methods and properties for administering this service.
Point3DLayer
- classarcgis.layers.Point3DLayer(url:str,gis=None,parent_url=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 isused.# USAGE EXAMPLE 1: Instantiating a SceneLayer objectfromarcgis.layersimportSceneLayers_layer=SceneLayer(url='https://your_portal.com/arcgis/rest/services/service_name/SceneServer/')type(s_layer)>>arcgis.layers.Point3DLayerprint(s_layer.properties.layers[0].name)>>'your layer name'
- propertymanager:SceneLayerManager|EnterpriseSceneLayerManager
The
manager
property returns an instance ofSceneLayerManager
classorEnterpriseSceneLayerManager
classwhich provides methods and properties for administering this service.
PointCloudLayer
- classarcgis.layers.PointCloudLayer(url:str,gis=None,parent_url=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 isused.# USAGE EXAMPLE 1: Instantiating a SceneLayer objectfromarcgis.layersimportSceneLayers_layer=SceneLayer(url='https://your_portal.com/arcgis/rest/services/service_name/SceneServer/')type(s_layer)>>arcgis.layers.PointCloudLayerprint(s_layer.properties.layers[0].name)>>'your layer name'
- propertymanager:SceneLayerManager|EnterpriseSceneLayerManager
The
manager
property returns an instance ofSceneLayerManager
classorEnterpriseSceneLayerManager
classwhich provides methods and properties for administering this service.
VoxelLayer
- classarcgis.layers.VoxelLayer(url:str,gis=None,parent_url=None)
Bases:
Layer
The
VoxelLayer
class represents a Web Scene Voxel layer.Note
Web scene layers are cached web layers that are optimized for displayinga 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 objectfromarcgis.layersimportSceneLayers_layer=SceneLayer(url='https://your_portal.com/arcgis/rest/services/service_name/SceneServer/')type(s_layer)>>arcgis.layers.VoxelLayerprint(s_layer.properties.layers[0].name)>>'your layer name'
- propertymanager:SceneLayerManager|EnterpriseSceneLayerManager
The
manager
property returns an instance ofSceneLayerManager
classorEnterpriseSceneLayerManager
classwhich provides methods and properties for administering this service.
Working with Map Service Layers
MapServiceLayer
- classarcgis.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 isused.# USAGE EXAMPLE 1: Instantiating a Map Service Layer objectfromarcgis.layersimportMapServiceLayerms_layer=MapServiceLayer(url='https://your_portal.com/arcgis/rest/services/service_name/MapServer/0')type(ms_layer)>>arcgis.layers.MapTableprint(ms_layer.properties.name)>>'pipe_properties'
MapFeatureLayer
- classarcgis.layers.MapFeatureLayer(url:str,gis:_gis.GIS|None=None,container:MapImageLayer|None=None,dynamic_layer:dict|None=None,time_filter:_dt.datetime|list[_dt.datetime]|list[str]|None=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 abroader resource (Item
) in theGIS
.MapFeatureLayer objects can be obtained through the layers attribute on map image service Items in theGIS
.- attachements
Deprecated since version 2.4.1:Use the attachments property instead.
Deprecated since version 2.4.1:Use the attachments property instead.
- propertyattachments:AttachmentManager
The
attachments
property provides a manager to work with attachments if theMapFeatureLayer
supports this functionality.
- propertycontainer:MapImageLayer
The
container
property represents theMapImageLayer
to which this layer belongs.
- export_attachments(output_folder:str,label_field:str|None=None)→str
The
export_attachments
method exports attachments from the map feature layer inImagenet
format usingtheoutput_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
- classmethodfromitem(item:Item,layer_id:int=0)→MapImageLayer
The
fromitem
method creates aMapFeatureLayer
from a GISItem
.Parameter
Description
item
Required
Item
object. The type of item should beaMapServiceLayer
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>>>fromarcgis.layersimportMapImageLayer,MapFeatureLayer>>>fromarcgis.gisimportGIS# 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)}")<StateBoundaries<class'arcgis.layers._msl.layer.MapFeatureLayer'>>
- generate_renderer(definition:dict[str,Any],where:str|None=None)→dict[str,Any]
The
generate_renderer
operation groups data using the supplied definition(classification definition) and an optional where clause. Theresult is a renderer object. UsebaseSymbol
andcolorRamp
to definethe symbols assigned to each class.Note
If the operation is performedon a table, the result is a renderer object containing the dataclasses 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 theclassification definitionspage in the ArcGIS REST API documentation for more information.
where
Optional string. A where clause for which the data needs to beclassified. Any legal SQL where clause operating on the fields inthe dynamic layer/table is allowed.
- Returns:
dictionary
- get_html_popup(oid:str)→dict|str
The
get_html_popup
resource provides details about the HTML pop-upauthored 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:str,query_string:str='1=1')→list
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 attributesbefore unique values are returned.
- Returns:
A List
# USAGE EXAMPLE>>>fromarcgis.layersimportMapImageLayer,MapFeatureLayer>>>fromarcgis.gisimportGIS# 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:str='1=1',text:str|None=None,out_fields:str|list[str]='*',time_filter:list[int]|list[_dt.datetime]|dict[str,_dt.datetime]|None=None,geometry_filter:GeometryFilter|None=None,return_geometry:bool=True,return_count_only:bool=False,return_ids_only:bool=False,return_distinct_values:bool=False,return_extent_only:bool=False,group_by_fields_for_statistics:str|None=None,statistic_filter:StatisticFilter|None=None,result_offset:int|None=None,result_record_count:int|None=None,object_ids:str|None=None,distance:int|None=None,units:str|None=None,max_allowable_offset:float|None=None,out_sr:int|None=None,geometry_precision:int|None=None,gdb_version:str|None=None,order_by_fields:str|None=None,out_statistics:list[dict[str,Any]]|None=None,return_z:bool=False,return_m:bool=False,multipatch_option=None,quantization_parameters:dict[str,Any]|None=None,return_centroid:bool=False,return_all_records:bool=True,result_type:str|None=None,historic_moment:int|_dt.datetime|None=None,sql_format:str|None=None,return_true_curves:bool=False,return_exceeded_limit_features:bool|None=None,as_df:bool=False,datum_transformation:int|dict[str,Any]|None=None,range_values:dict[str,Any]|None=None,parameter_values:dict[str,Any]|None=None,**kwargs)→_features.FeatureSet|int|dict|pd.DataFrame
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 displayfield associated with it, the server searches for this text in thisfield.
out_fields
Optional List of field names to return. Field names can be specifiedeither 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 thedistance is 100, the query geometry is a point, units is set tometers, and all points within 100 meters of the point are returned.
units
Optional string. The unit for calculating the buffer distance. Ifunit is not specified, the unit is derived from the geometry spatialreference. If the geometry spatial reference is not specified, theunit is derived from the feature service data spatial reference.This parameter only applies ifsupportsQueryWithDistance istrue.
- Value options:
esriSRUnit_Meter
|esriSRUnit_StatuteMile
|esriSRUnit_Foot
|esriSRUnit_Kilometer
|esriSRUnit_NauticalMile
|esriSRUnit_USNauticalMile
time_filter
Optional list ofstartTime andendTime values.:Syntax:
>>>time_filter=[<startTime>,<endTime>]
Note
Specified as
_dt.datetime.date
,_dt.datetime._dt.datetime
ortimestamp
in millisecondsgeometry_filter
Optional
filter
object. Allows forthe information to be filtered on spatial relationship with anothergeometry.max_allowable_offset
Optional float. This option can be used to specify themax_allowable_offset to be used for generalizing geometriesreturned by the query operation in the units ofout_sr. Ifout_sr is not specified, the value is in units of the spatialreference of the layer.
out_sr
Optional Integer. The WKID for the spatial reference of the returnedgeometry.
geometry_precision
Optional Integer. This option can be used to specify the number ofdecimal places in the response geometries returned by the queryoperation.This applies to X and Y values only (not m or z-values).
gdb_version
Optional string. The geodatabase version to query. This parameterapplies only if theisDataVersioned property of the layer is true.If not specified, the query will apply to the published map’sversion.
return_geometry
Optional boolean. Iftrue, geometry is returned with the query.Default istrue.
return_distinct_values
Optional boolean. IfTrue, it returns distinct values based onfields specified inout_fields. This parameter applies only if thesupportsAdvancedQueries property of the layer is true.
return_ids_only
Optional boolean. Default isFalse. IfTrue, the response onlyincludes an array of object IDs. Otherwise, the response is a
FeatureSet
.return_count_only
Optional boolean. IfTrue, the response only includes the countof features/records satisfying the query. Otherwise, the response isa
FeatureSet
. The default isFalse. Thisoption supersedes thereturns_ids_only parameter. IfreturnCountOnly=True
, the response will return both the countand the extent.return_extent_only
Optional boolean. IfTrue, the response only includes the extentof the features satisfying the query. IfreturnCountOnly=true, theresponse will return both the count and the extent. The default isFalse. This parameter applies only if thesupportsReturningQueryExtent property of the layer istrue.
order_by_fields
Optional string. One or more field names by which to order theresults. Use
ASC
orDESC
for ascendingor 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 resultsfor calculating the statistics.
>>>group_by_fields_for_statiscits="STATE_NAME, GENDER"
out_statistics
Optional List. The definitions for one or more field-basedstatistics 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. IfTrue, Z values are included in the results ifthe features have Z values. Otherwise, Z values are not returned.The default isFalse.
return_m
Optional boolean. IfTrue, M values are included in the results ifthe features have M values. Otherwise, M values are not returned.The default isFalse.
multipatch_option
Optional x/y footprint. This option dictates how the geometry ofa multipatch feature will be returned.
result_offset
Optional integer. This option can be used for fetching query resultsby skipping the specified number of records and starting from thenext record (that is,resultOffset + ith value). This option isignored ifreturn_all_records isTrue (i.e. by default).This parameter cannot be specified if the service does not support pagination.
result_record_count
Optional integer. This option can be used for fetching query resultsup to theresult_record_count specified. Whenresult_offset isspecified but this parameter is not, the map service defaults it tomax_record_count. The maximum value for this parameter is the valueof the layer’smaxRecordCount property. This option is ignored ifreturn_all_records is True (i.e. by default).This parameter cannot be specified if the service does not support pagination.
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 associatedwith each feature returned. IfTrue, the result includes thegeometry centroid. The default isFalse.
return_all_records
Optional boolean. WhenTrue, the query operation will call theservice until all records that satisfy thewhere_clause arereturned.
Note
result_offset andresult_record_count will beignored if set toTrue. Ifreturn_count_only,return_ids_only,orreturn_extent_only areTrue, this parameter is ignored.
result_type
Optional string. Controls the number of features returned by theoperation.Options:
None
|standard
|tile
Note
SeeQuery (Feature Service/Layer)for full explanation.
historic_moment
Optional integer. The historic moment to query. This parameterapplies only if the layer is archiving enabled and thesupportsQueryWithHistoricMoment property is set totrue. Thisproperty is provided in the layer’s
properties
resource. Ifnot specified, the query will apply to the current features.sql_format
Optional string. Thesql_format parameter can be either standardSQL92 or it can use the native SQL of the underlyingdatastore. The default isNone, which means it depends on theuseStandardizedQuery layer property.Values:
None
|standard
|native
return_true_curves
Optional boolean. When set toTrue, returns true curves in outputgeometries. When set toFalse, curves are converted to densifiedpolylines or polygons.
return_exceeded_limit_features
Optional boolean. Optional parameter which is true by default. Whenset to true, features are returned even when the results includetheexceededTransferLimit: True property.
When set toFalse and querying withresultType = tile, featuresare not returned when the results includeexceededTransferLimit: True. This allows a client to find theresolution in which the transfer limit is no longer exceeded withoutmaking multiple calls.
as_df
Optional boolean. IfTrue, the results are returned as aDataFrame instead of a
FeatureSet
.datum_transformation
Optional Integer/Dictionary. This parameter applies a datum transformation whileprojecting geometries in the results when out_sr is different than the layer’s spatialreference. When specifying transformations, you need to think about which datumtransformation best projects the layer (not the feature service) to theoutSR andsourceSpatialReference property in the layer properties. For a list of valid datumtransformation ID values ad well-known text strings, seeCoordinate systems andtransformations.For more information on datum transformations, please see the transformationparameter in theProject 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 arewithin 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 specifyingvalue(s) to an array of pre-authored parameterized filters for thoselayers. When value is not specified for any parameter in a request,the default value, that is assigned during authoring time, gets usedinstead.
When aparameterInfo allows multiple values, you must pass them inan array.
Note
CheckparameterValues at theQuery (Map Service/Layer)for details on parameterized filters.
kwargs
Optional dict. Optional parameters that can be passed to the Queryfunction. This will allow users to pass additional parameters notexplicitly implemented on the function. A complete list of functionsavailable is documented atQuery (Feature Service/Layer).
- Returns:
A
FeatureSet
containing the features matching the query unless another
return type is specified, such as
count
.# USAGE EXAMPLE>>>fromarcgis.layersimportMapImageLayer,MapFeatureLayer>>>fromarcgis.gisimportGIS# 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>
- query_related_records(object_ids:str,relationship_id:str,out_fields:str|list[str]='*',definition_expression:str|None=None,return_geometry:bool=True,max_allowable_offset:float|None=None,geometry_precision:int|None=None,out_wkid:int|None=None,gdb_version:str|None=None,return_z:bool=False,return_m:bool=False,historic_moment:int|_dt.datetime|None=None,return_true_curve:bool=False)→dict
The
query_related_records
operation is performed on aMapFeatureLayer
resource. The result of this operation areFeatureSet
objects groupedby source layer/table object IDs. EachFeatureSet
containsFeature
objects including the values for the fields requested bythe user.Note
For related layers, if you request geometryinformation, the geometry of each feature is also returned inthe feature set. For related tables, the feature set does notinclude 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/layerto be included in the returned feature set. This list is a commadelimited list of field names. If you specify the shape field in thelist of return fields, it is ignored. To request geometry, setreturn_geometry to true. You can also specify the wildcard “*” asthe value of this parameter. In this case, the results will includeall the field values.
definition_expression
Optional string. The definition expression to be applied to therelated table/layer. From the list of objectIds, only those recordsthat conform to this expression are queried for related records.
return_geometry
Optional boolean. If true, the feature set includes the geometryassociated with each feature. The default is true.
max_allowable_offset
Optional float. This option can be used to specify themax_allowable_offset to be used for generalizing geometries returnedby the query operation. The max_allowable_offset is in the units ofthe outSR. If out_wkid is not specified, then max_allowable_offsetis 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 ofdecimal 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 parameterapplies only if the isDataVersioned property of the layer queried istrue.
return_z
Optional boolean. If true, Z values are included in the results ifthe 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 ifthe 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 parameterapplies only if the supportsQueryWithHistoricMoment property of thelayers being queried is set to true. This setting is provided in thelayer resource.
If historic_moment is not specified, the query will apply to thecurrent features.
- Syntax:
historic_moment=<Epoch time in milliseconds>
return_true_curves
Optional boolean. Optional parameter that is false by default. Whenset to true, returns true curves in output geometries; otherwise,curves are converted to densified polylines or polygons.
- Returns:
dict
- propertyrenderer:dict|None
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
- propertytime_filter:str
Starting at Enterprise 10.7.1+, instead of querying time-enabledmap service layers or time-enabled feature service layers, atime 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 valuescomma.>>>import_dt.datetimeasdt>>>map_feature_lyr.time_filter=[dt._dt.datetime(2021,1,1),dt._dt.datetime(2022,1,10)]
MapRasterLayer
- classarcgis.layers.MapRasterLayer(url:str,gis:_gis.GIS|None=None,container:MapImageLayer|None=None,dynamic_layer:dict|None=None,time_filter:_dt.datetime|list[_dt.datetime]|list[str]|None=None)
Bases:
MapFeatureLayer
The
MapRasterLayer
class represents a geo-referenced image hosted in aMapService
.
MapImageLayer
- classarcgis.layers.MapImageLayer(url:str,gis:GIS|None=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:dict[str,Any])→FeatureLayer|None
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 Serveror of a registered workspace. This resource is supported only when the map image layersupports dynamic layers, as indicated bysupportsDynamicLayers
onthe 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>>>fromarcgis.layersimportMapImageLayer>>>fromarcgis.gisimportGIS# 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":<layersource>"definitionExpression":"<definitionExpression>","drawingInfo":{"renderer":<renderer>,"transparency":<transparency>,"scaleSymbols":<true>,"showLabels":<true>,"labelingInfo":<labelinginfo>},"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:str,levels:str,tile_package:bool=False,export_extent:str='DEFAULT',area_of_interest:dict[str,Any]|Polygon|None=None,asynchronous:bool=True,**kwargs)→dict
The
estimate_export_tiles_size
method is an asynchronous task thatallows estimation of the size of the tile package or the cache dataset that you download using theexport_tiles
operation. Thisoperation can also be used to estimate the tile count in a tilepackage and determine if it will exceed themaxExportTileCount
limit set by the administrator of the service. The result of thisoperation isMapServiceJob
. This job response contains referencetoMapServiceResult
resource that returns the total size of thecache to be exported (in bytes) and the number of tiles that willbe exported.Parameter
Description
export_by
Required string. The criteria that will be used to select the tileservice levels to export. The values can be Level IDs, cache scalesor the Resolution (in the case of image services).Values:
“levelId” | “resolution” | “scale”
levels
Required string. Specify the tiled service levels for which you wantto 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,9Example 2: 1-4,7-9
tile_package
Optional boolean. Allows estimating the size for either a tilepackage or a cache raster data set. Specify the value true for tilepackages format and false for Cache Raster data set. The defaultvalue is False
export_extent
The extent (bounding box) of the tile package or the cache datasetto be exported. If extent does not include a spatial reference, theextent 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 withinthe specified polygon areas. This parameter supersedes extentparameter.
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 asynchronouslyrequiring the tool status to be checked manually to force it torun synchronously the tool will check the status until theestimation completes. The default is True, which means the statusof the job and results need to be checked manually. If the valueis set to False, the function will wait until the task completes.
- Returns:
dictionary
- export_map(bbox:str,bbox_sr:int|None=None,size:str='600,550',dpi:int=200,image_sr:int|None=None,image_format:int='png',layer_defs:dict[str,Any]|None=None,layers:str|None=None,transparent:bool=False,time_value:list[int]|list[_dt.datetime._dt.datetime]|None=None,time_options:dict[str,Any]|None=None,dynamic_layers:dict[str,Any]|None=None,gdb_version:str|None=None,scale:float|None=None,rotation:float|None=None,transformation:list[int]|list[dict[str,Any]]|None=None,map_range_values:list[dict[str,Any]]|None=None,layer_range_values:list[dict[str,Any]]|None=None,layer_parameter:list[dict[str,Any]]|None=None,f:str='json',save_folder:str|None=None,save_file:str|None=None,**kwargs)→str
The
export_map
operation is performed on a map service resource.The result of this operation is a map image resource. Thisresource provides information about the exported map image suchas 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 assumedto 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 individuallayers in the exported map by specifying definition expressions forthose layers. Definition expression for a layer that ispublished 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 thebackground color of the map set as its transparent color. Thedefault is false.
Note
Only the .png and .gif formats supporttransparency.
time_value
Optional list. The time instant or the time extent of the featuresto be identified.
time_options
Optional dict. The time options per layer. Users can indicatewhether or not the layer should use the time extent specified by thetime parameter or not, whether to draw the layer featurescumulatively or not and the time offsets for the layer.
dynamic_layers
Optional dict. Use dynamicLayers property to reorder layers andchange the layer data source. dynamicLayers can also be used to addnew layer that was not defined in the map used to create the mapservice. The new layer should have its source pointing to one of theregistered workspaces that was defined at the time the map servicewas created.The order of dynamicLayers array defines the layer drawing order.The first element of the dynamicLayers is stacked on top of allother layers. When defining a dynamic layer, source is required.
gdb_version
Optional string. Switch map layers to point to an alternategeodatabase version.
scale
Optional float. Use this parameter to export a map image at aspecific map scale, with the map centered around the center of thespecified bounding box (bbox)
rotation
Optional float. Use this parameter to export a map image rotated ata specific angle, with the map centered around the center of thespecified bounding box (bbox). It could be positive or negativenumber.
transformations
Optional list. Use this parameter to apply one or more datumtransformations to the map when sr is different than the mapservice’s spatial reference. It is an array of transformationelements.
map_range_values
Optional list. Allows you to filter features in the exported mapfrom all layer that are within the specified range instant orextent.
layer_range_values
Optional dictionary. Allows you to filter features for eachindividual layer that are within the specified range instant orextent. Note: Check range infos at the layer resources for theavailable ranges.
layer_parameter
Optional list. Allows you to filter the features of individuallayers in the exported map by specifying value(s) to an array ofpre-authored parameterized filters for those layers. When value isnot 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>>>fromarcgis.layersimportMapImageLayer>>>fromarcgis.gisimportGIS# 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:str,export_by:str='LevelID',tile_package:bool=True,export_extent:dict[str,Any]|str|None=None,optimize_for_size:bool=True,compression:int=75,area_of_interest:dict[str,Any]|Polygon|None=None,asynchronous:bool=False,storage_format:str|None=None,**kwargs)→str|dict
The
export_Tiles
operation is performed as an asynchronous task andallows client applications to download map tiles from a server foroffline use. This operation is performed on aMapService
thatallows clients to export cache tiles. The result of this operationis aMapServiceJob
. This job response contains a reference to theMapServiceResult
resource, which returns a URL to the resultingtile package (.tpk) or a cache raster dataset.export_Tiles
can be enabled in a service by using ArcGIS Desktopor the ArcGIS Server Administrator Directory. In ArcGIS Desktopmake an admin or publisher connection to the server, go to serviceproperties, and enableAllowClients
toExportCacheTiles
in theadvanced caching page of theServiceEditor
. You can also specifythe maximum tiles clients will be allowed to download.Note
The default maximum allowed tile count is 100,000. To enable this capabilityusing the Administrator Directory, edit the service, and set theproperties
exportTilesAllowed
=True
andmaxExportTilesCount
= 100000.Note
In ArcGIS Server 10.2.2 and later versions, exportTiles is supported as anoperation 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 definedin the following parameters table:Parameter
Description
levels
Required string. Specifies the tiled service levels to export. Thevalues should correspond to Level IDs, cache scales. or theresolution as specified in export_by parameter. The values can becomma separated values or a range. Make sure tiles are present atthe levels where you attempt to export tiles.Example 1: 1,2,3,4,5,6,7,8,9Example 2: 1-4,7-9
export_by
Required string. The criteria that will be used to select the tileservice 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 cacheraster data set. If the value is true, output will be in tilepackage format, and if the value is false, a cache raster dataset is returned. The default value is True.
export_extent
Optional dictionary or string. The extent (bounding box) of the tilepackage or the cache dataset to be exported. If extent does notinclude a spatial reference, the extent values are assumed to be inthe spatial reference of the map. The default value is full extentof the tiled map service.Syntax:
<xmin>, <ymin>, <xmax>, <ymax>
Example 1: -104,35.6,-94.32,41Example 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 JPEGtiles and reduce the size of the downloaded tile package or thecache raster data set. Compressing tiles slightly compromises thequality of tiles but helps reduce the size of the download. Trysample compressions to determine the optimal compression beforeusing this feature.The default value is True.
compression=75,
Optional integer. When optimize_for_size=true, you can specify acompression factor. The value must be between 0 and 100. The valuecannot be greater than the default compression already set on theoriginal tile. For example, if the default value is 75, the valueof compressionQuality must be between 0 and 75. A value greaterthan 75 in this example will attempt to up sample an alreadycompressed tile and will further degrade the quality of tiles.
area_of_interest
Optional dictionary, Polygon. The area_of_interest polygon allowsexporting tiles within the specified polygon areas. This parametersupersedes 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 arereturned to the user instead of the user having the check the jobstatus 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:str,layers:str,contains:bool=True,search_fields:str|None=None,sr:dict[str,Any]|str|SpatialReference|None=None,layer_defs:dict[str,Any]|None=None,return_geometry:bool=True,max_offset:int|None=None,precision:int|None=None,dynamic_layers:dict[str,Any]|None=None,return_z:bool=False,return_m:bool=False,gdb_version:str|None=None,return_unformatted:bool=False,return_field_name:bool=False,transformations:list[int]|list[dict[str,Any]]|None=None,map_range_values:list[dict[str,Any]]|None=None,layer_range_values:dict[str,Any]|None=None,layer_parameters:list[dict[str,Any]]|None=None,**kwargs)→dict
The
find
method performs the map servicefind
operation.Parameter
Description
search_text
Required string.The search string. This is the text that is searchedacross 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 exactmatch of the search_text string. An exact match is case sensitive.Otherwise, it searches for a value that contains the search_textprovided. 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 thespatial reference of the input and output geometries as well as themap_extent. If sr is not specified, the geometry and the map_extentare assumed to be in the spatial reference of the map, and theoutput geometries are also in the spatial reference of the map.
layer_defs
Optional dict. Allows you to filter the features of individuallayers in the exported map by specifying definition expressions forthose layers. Definition expression for a layer that ispublished with the service will be always honored.
return_geometry
Optional boolean. If true, the resultset will include the geometriesassociated with each result. The default is true.
max_offset
Optional integer. This option can be used to specify the maximumallowable offset to be used for generalizing geometries returned bythe identify operation.
precision
Optional integer. This option can be used to specify the number ofdecimal places in the response geometries returned by the identifyoperation. This applies to X and Y values only (not m or z-values).
dynamic_layers
Optional dict. Use dynamicLayers property to reorder layers andchange the layer data source. dynamicLayers can also be used to addnew layer that was not defined in the map used to create the mapservice. The new layer should have its source pointing to one of theregistered workspaces that was defined at the time the map servicewas created.The order of dynamicLayers array defines the layer drawing order.The first element of the dynamicLayers is stacked on top of allother layers. When defining a dynamic layer, source is required.
return_z
Optional boolean. If true, Z values will be included in the resultsif 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 resultsif 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 alternategeodatabase version.
return_unformatted
Optional boolean. If true, the values in the result will not beformatted i.e. numbers will be returned as is and dates will bereturned as epoch values.
return_field_name
Optional boolean. If true, field names will be returned instead offield aliases.
transformations
Optional list. Use this parameter to apply one or more datumtransformations to the map when sr is different from the mapservice’s spatial reference. It is an array of transformationelements.
map_range_values
Optional list. Allows you to filter features in the exported mapfrom all layer that are within the specified range instant orextent.
layer_range_values
Optional dictionary. Allows you to filter features for eachindividual layer that are within the specified range instant orextent. Note: Check range infos at the layer resources for theavailable ranges.
layer_parameters
Optional list. Allows you to filter the features of individuallayers in the exported map by specifying value(s) to an array ofpre-authored parameterized filters for those layers. When value isnot specified for any parameter in a request, the default value,that is assigned during authoring time, gets used instead.
- Returns:
A dictionary
# USAGE EXAMPLE>>>fromarcgis.layersimportMapImageLayer>>>fromarcgis.gisimportGIS# 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>
- classmethodfromitem(item:Item)→MapImageLayer
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:str,name:str,layers:str,options:str='composite')→str
The
generate_Kml
operation is performed on a map service resource.The result of this operation is a KML document wrapped in a KMZfile.Note
The document contains a network link to the KML Serviceendpoint 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 optionchosen, the layers are drawn as one composite image, as separateimages, or as vectors. When the KML capability is enabled, theArcGIS Server administrator has the option of setting the layeroperations allowed. If vectors are not allowed, then the caller willnot be able to get vectors. Instead, the caller receives a singlecomposite image.values: composite, separateImage, nonComposite
- Returns:
A string to the file path
- identify(geometry:Geometry|list,map_extent:str,image_display:str|None=None,geometry_type:str='Point',sr:dict[str,Any]|str|SpatialReference=None,layer_defs:dict[str,Any]|None=None,time_value:list[str]|str=None,time_options:dict|None=None,layers:str='all',tolerance:int|None=None,return_geometry:bool=True,max_offset:int|None=None,precision:int=4,dynamic_layers:dict[str,Any]|None=None,return_z:bool=False,return_m:bool=False,gdb_version:str|None=None,return_unformatted:bool=False,return_field_name:bool=False,transformations:list[dict]|list[int]|None=None,map_range_values:list[dict[str,Any]]|None=None,layer_range_values:dict[str,Any]|None=None,layer_parameters:list[dict[str,Any]]|None=None,**kwargs)→dict
The
identify
operation is performed on a map service resourceto discover features at a geographic location. The result of thisoperation is an identify results resource.Note
Each identified result includes its
name
,layerID
,layername
,geometry
,geometrytype
, and other attributes of that result as name-value pairs.Parameter
Description
geometry
Required
Geometry
or list. The geometryto identify on. The type of the geometry is specified by thegeometryType parameter. The structure of the geometries is same asthe structure of the JSON geometry objects returned by the API (SeeGeometry Objects).In addition to the JSON structures, for points and envelopes, youcan specify the geometries with a simpler comma-separated syntax.geometry_type
Required string.The type of geometry specified by the geometryparameter. The geometry type could be a point, line, polygon, or anenvelope.Values:
“Point” | “Multipoint” | “Polyline” | “Polygon” | “Envelope”
map_extent
Required string. The extent or bounding box of the map currentlybeing viewed.
sr
Optional dict, string, or SpatialReference. The well-known ID of thespatial reference of the input and output geometries as well as themap_extent. If sr is not specified, the geometry and the map_extentare assumed to be in the spatial reference of the map, and theoutput geometries are also in the spatial reference of the map.
layer_defs
Optional dict. Allows you to filter the features of individuallayers in the exported map by specifying definition expressions forthose layers. Definition expression for a layer that ispublished with the service will be always honored.
time_value
Optional list. The time instant or the time extent of the featuresto be identified.
time_options
Optional dict. The time options per layer. Users can indicatewhether or not the layer should use the time extent specified by thetime parameter or not, whether to draw the layer featurescumulatively 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 specifiedgeometry within which the
identify
operation should be performed. The value forthe 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 theimage_display parameters are used by the server to determine thelayers visible in the current extent. They are also used tocalculate the distance on the map to search based on the tolerancein screen pixels.
Syntax:
<width>, <height>, <dpi>
return_geometry
Optional boolean. If true, the result set will include the geometriesassociated with each result. The default is true.
max_offset
Optional integer. This option can be used to specify the maximumallowable offset to be used for generalizing geometries returned bythe identify operation.
precision
Optional integer. This option can be used to specify the number ofdecimal places in the response geometries returned by the identifyoperation. This applies to X and Y values only (not m or z-values).
dynamic_layers
Optional dict. Use dynamicLayers property to reorder layers andchange the layer data source. dynamicLayers can also be used to addnew layer that was not defined in the map used to create the mapservice. The new layer should have its source pointing to one of theregistered workspaces that was defined at the time the map servicewas created.The order of dynamicLayers array defines the layer drawing order.The first element of the dynamicLayers is stacked on top of allother layers. When defining a dynamic layer, source is required.
return_z
Optional boolean. If true, Z values will be included in the resultsif 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 resultsif 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 alternategeodatabase version.
return_unformatted
Optional boolean. If true, the values in the result will not beformatted i.e. numbers will be returned as is and dates will bereturned as epoch values. The default is False.
return_field_name
Optional boolean. Default is False. If true, field names will bereturned instead of field aliases.
transformations
Optional list. Use this parameter to apply one or more datumtransformations to the map when sr is different than the mapservice’s spatial reference. It is an array of transformationelements.Transformations specified here are used to project features fromlayers within a map service to sr.
map_range_values
Optional list of dictionary(ies). Allows for the filtering features inthe exported map from all layer that are within the specified rangeinstant or extent.
layer_range_values
Optional Dictionary. Allows for the filtering of featuresfor each individual layer that are within the specified range instant orextent.
layer_parameters
Optional list of dictionary(ies). Allows for the filtering of thefeatures of individual layers in the exported map by specifying value(s)to an array of pre-authored parameterized filters for those layers. Whenvalue is not specified for any parameter in a request, the defaultvalue, that is assigned during authoring time, gets used instead.
- Returns:
A dictionary
# USAGE EXAMPLE>>>fromarcgis.layersimportMapImageLayer>>>fromarcgis.gisimportGIS# 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,return_m=True,return_field_name=True,)>>>type(identified)<Dictionary>
- propertyitem_info:dict
The
item_info
method retrieves the service’s item’s information.- Returns:
A dictionary
- propertylegend:dict
The
legend
property represents a map service’s legend. It returnsthe legend information for all layers in the service. Each layer’slegend information includes the symbol images and labels for eachsymbol. 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 asa url that could be used to retrieve the image from the server.
- Returns:
Dictionary of legend information
- propertymanager:MapImageLayerManager|EnterpriseMapImageLayerManager
The
manager
property returns an instance ofMapImageLayerManager
classfor ArcGIS Online andEnterpriseMapImageLayerManager
class for ArcGIS Enterprisewhich provides methods and properties for administering this service.
MapImageLayerManager
- classarcgis.layers.MapImageLayerManager(url:str,gis:GIS|None=None,map_img_lyr:MapImageLayer|None=None)
Bases:
_GISResource
The
MapImageLayerManager
class allows administration (if access permits) of ArcGIS Online Hosted Tile Layersor Cached Map Services.AMapImageLayer
offers access to the Map Server endpointsthat 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 /MapServerwhen instantiating that class.
Note
Map Image Layers are created from Enterprise Services and their manager canbe accessed through the EnterpriseMapImageLayerManager.
- cancel_job(job_id:str)→dict
The
cancel_job
operation supports cancelling a job while updatetiles is running from a hosted feature service. The result of thisoperation is a response indicating success or failure with errorcode and description.Parameter
Description
job_id
Required String. The job id to cancel.
- delete_tiles(levels:str,extent:dict[str,int]|None=None)→dict
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 withinthis extent will be deleted or will be deleted basedon the service’s full extent.
- Returns:
A dictionary
# USAGE EXAMPLE>>>fromarcgis.layersimportMapImageLayer>>>fromarcgis.gisimportGIS# 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:str|None=None,min_scale:float|None=None,max_scale:float|None=None,source_item_id:str|None=None,export_tiles_allowed:bool=False,max_export_tile_count:float=100000)→dict
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 forcaching.
max_scale
Required float. Sets the services maximum scale forcaching.
source_item_id
Required String. The Source Item ID is theGeoWarehouse Item ID of the map service
export_tiles_allowed
Required boolean.
exports_tiles_allowed
sets thevalue to let users export tilesmax_export_tile_count
Optional float.
max_export_tile_count
sets themaximum amount of tiles to be exported from a singlecall.Note
The default value is 100000.
# USAGE EXAMPLE>>>fromarcgis.layersimportMapImageLayer>>>fromarcgis.gisimportGIS# 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:Item,levels:str|list[int]|None=None,extent:str|dict[str,int]|None=None,merge:bool=False,replace:bool=False)→dict
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>>>fromarcgis.layersimportMapImageLayer>>>fromarcgis.gisimportGIS# 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()→dict
The
refresh
operation refreshes a service, which clears the webserver cache for the service.
- propertyrerun_job:dict
The
rerun_job
operation supports re-running a canceled job from ahosted map service. The result of this operation is a responseindicating 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 givenjobs with a specific errorcode:
ALL|ERROR|CANCELED
- Returns:
A boolean or dictionary
- update_tiles(levels:str|list[int]|None=None,extent:str|dict[str,int]|None=None,merge:bool=False,replace:bool=False)→dict|None
The
update_tiles
method starts tile generation for ArcGIS Online. The levels of detailand the extent are needed to determine the area where tiles needto be rebuilt.Note
The
update_tiles
operation is for ArcGIS Online only.Parameter
Description
levels
Optional String / List of integers, The level of detailsto update. Example: “1,2,10,20” or [1,2,10,20]
extent
Optional String / Dict. The area to update as Xmin, YMin, XMax, YMaxExample:
“-100,-50,200,500” or {‘xmin’:100, ‘ymin’:200, ‘xmax’:105, ‘ymax’:205}
merge
Optional Boolean. Default is false and applicable tocompact cache storage format. It controls whetherthe bundle files from the TPK file are merged withthe one in the existing cached service. Otherwise,the bundle files are overwritten.
replace
Optional Boolean. Default is false, applicable tocompact cache storage format and used whenmerge=true. It controls whether the new tiles willreplace the existing ones when merging bundles.
- Returns:
Dictionary. If the product is not ArcGIS Online tile service, theresult will be None.
# USAGE EXAMPLE>>>fromarcgis.layersimportMapImageLayer>>>fromarcgis.gisimportGIS# 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
- classarcgis.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:str)→bool
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:dict)→bool
To edit a service, you need to submit the complete JSONrepresentation of the service, which includes the updates to theservice properties. Editing a service causes the service to berestarted with updated properties.
Parameter
Description
service_dictionary
Required dict. The service JSON as a dictionary.
- Returns:
boolean
MapTable
- classarcgis.layers.MapTable(url:str,gis:_gis.GIS|None=None,container:MapImageLayer|None=None,dynamic_layer:dict|None=None,time_filter:_dt.datetime|list[_dt.datetime]|list[str]|None=None)
Bases:
MapFeatureLayer
The
MapTable
class represents entity classes with uniform properties.Note
In addition to working with entities with
location
asfeatures, 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 relatedoperation.- classmethodfromitem(item:Item,table_id:int=0)→MapTable
The
fromitem
method creates aMapTable
from a GISItem
.Parameter
Description
item
Required
Item
object. The type of item should beaMapImageService
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>>>fromarcgis.layersimportMapImageLayer,MapTable>>>fromarcgis.gisimportGIS# 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)}")<StateBoundaries<class'arcgis.layers.MapTable'>>
- query(where:str='1=1',out_fields:str|list[str]='*',time_filter:_dt.datetime|list[_dt.datetime]|list[str]|dict[_dt.datetime]|None=None,return_count_only:bool=False,return_ids_only:bool=False,return_distinct_values:bool=False,group_by_fields_for_statistics:str|None=None,statistic_filter:StatisticFilter|None=None,result_offset:int|None=None,result_record_count:int|None=None,object_ids:str|None=None,gdb_version:str|None=None,order_by_fields:str|None=None,out_statistics:list[dict]|None=None,return_all_records:bool=True,historic_moment:int|_dt.datetime|None=None,sql_format:str|None=None,return_exceeded_limit_features:bool|None=None,as_df:bool=False,range_values:list[dict[str,Any]]|None=None,parameter_values:list[dict[str,Any]]|None=None,**kwargs)→int|dict|_features.FeatureSet
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 specifiedeither 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.datetimeasdt>>>time_filter=[dt._dt.datetime(2022,1,1),dt.dateime(2022,1,12)]
gdb_version
Optional string. The geodatabase version to query. This parameterapplies only if theisDataVersioned property of the layer istrue. If this is not specified, the query will apply to thepublished map’s version.
return_geometry
Optional boolean. IfTrue, geometry is returned with the query.Default isTrue.
return_distinct_values
Optional boolean. IfTrue, it returns distinct values based onthe fields specified inout_fields. This parameter applies only ifthesupportsAdvancedQueries property of the layer istrue.
return_ids_only
Optional boolean. Default is False. IfTrue, the response onlyincludes an array of object IDs. Otherwise, the response is a
FeatureSet
.return_count_only
Optional boolean. IfTrue, 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 isFalse. This option supersedes thereturn_ids_only parameter. Ifreturn_count_only = True, theresponse will return both the count and the extent.order_by_fields
Optional string. One or more field names by which to order theresults. Use
ASC
orDESC
for ascendingor 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 resultsfor calculating the statistics.
>>>group_by_fields_for_statiscits="STATE_NAME, GENDER"
out_statistics
Optional string. The definitions for one or more field-basedstatistics 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 resultsby skipping the specified number of records and starting from thenext record (that is,result_offset + ith). This option is ignoredifreturn_all_records isTrue (i.e. by default).
result_record_count
Optional integer. This option can be used for fetching query resultsup to theresult_record_count specified. Whenresult_offset isspecified but this parameter is not, the map service defaults it tomax_record_count. The maximum value for this parameter is the valueof the layer’smaxRecordCount property. This option is ignored ifreturn_all_records isTrue (i.e. by default).
return_all_records
Optional boolean. WhenTrue, the query operation will call theservice until all records that satisfy thewhere_clause arereturned. Note:result_offset andresult_record_count will beignored ifreturn_all_records is True. Also, ifreturn_count_only,return_ids_only, orreturn_extent_only areTrue, this parameter will be ignored.
historic_moment
Optional integer. The historic moment to query. This parameterapplies only if the layer is archiving enabled and thesupportsQueryWithHistoricMoment property is set totrue. Thisproperty is provided in the layer resource.
Note
SeeQuery (Feature Service/Layer)for full explanation of layer properties. Use
properties
to examine layer properties.Ifhistoric_moment is not specified, the query will apply to thecurrent features.
sql_format
Optional string. Thesql_format parameter can be either standardSQL92 or it can use the native SQL of the underlyingdatastore. The default is none which means the sql_formatdepends on theuseStandardizedQuery parameter.Values:
none
|standard
|native
return_exceeded_limit_features
Optional boolean. Optional parameter which istrue by default.When set totrue, features are returned even when the resultsinclude theexceededTransferLimit: true property.
When set to false and querying withresultType = ‘tile’, featuresare not returned when the results includeexceededTransferLimit: True. This allows a client to find theresolution in which the transfer limit is no longer exceeded withoutmaking multiple calls.
as_df
Optional boolean. IfTrue, the results are returned as aDataFrame instead of a
FeatureSet
.range_values
Optional List. Allows you to filter features from the layer that arewithin 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 specifyingvalue(s) to an array of pre-authored parameterized filters for thoselayers. When value is not specified for any parameter in a request,the default value, that is assigned during authoring time, gets usedinstead.
WhenparameterInfo allows multiple values, you must pass them inan array.
Note: CheckparameterInfos at the layer
properties
forthe available parameterized filters, their default values andexpected data type.kwargs
Optional dict. Optional parameters that can be passed to the Queryfunction. This will allow users to pass additional parameters notexplicitly implemented on the function. A complete list of possibleparameters is documented atQuery (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>>>fromarcgis.layersimportMapImageLayer,MapFeatureLayer>>>fromarcgis.gisimportGIS# 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
- classarcgis.layers.VectorTileLayer(url,gis,parent_url=None)
Bases:
Layer
A Vector Tile Layer is a type of data layer used to access and displaytiled data and its corresponding styles. This is stored as an item in ArcGISand is used to access a vector tile service. Layer data include itsname, description, and any overriding style definition.
- export_tiles(levels:str|None=None,export_extent:dict[str,Any]|None=None,polygon:dict[str,Any]|Polygon|None=None,create_item:bool=False)→str|Item
Export vector tile layer
Parameter
Description
levels
Optional string.Specifies the tiled service levels to export.The values should correspond to Level IDs. The valuescan 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//Rangevalues>>>levels=1-4,7-9
export_extent
Optional dictionary of the extent (bounding box) of the vectortile 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 createdfrom 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
- classmethodfromitem(item)→VectorTileLayer
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)
- propertyinfo:list
The
info
property retrieves the relative paths to a list of resource files.- Returns:
A list of relative paths
- propertymanager:VectorTileLayerManager
The
manager
property returns an instance ofVectorTileLayerManager
class orEnterpriseVectorTileLayerManager
classwhich provides methods and properties for administering this service.
- propertystyles:dict
The styles property returns styles for vector tiles in Mapbox GLStyle specification version 8. The response for this styles resourceincludes the sprite and glyphs properties, with a relative pathto 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:str,stack_range:str)→str
The
tile_fonts
method retrieves glyphs inprotocol buffer format.Parameter
Description
fontstack
Required string.
Note
The template url for this font resource is represented in theVector Tile Styleresource.
stack_range
Required string that depict a range. Ex: “0-255”
- Returns:
Glyphs in PBF format
- propertytile_map:dict
The tile_map property describes a quadtree of tiles and can be used toavoid requesting tiles that don’t exist in the server. Each nodeof the tree has an associated tile. The root node (lod 0) coversthe entire extent of the data. Children are identified by their positionwith NW, NE, SW, and SE. Tiles are identified by lod/h/v, where h and vare indexes on a 2^lod by 2^lod grid . These values are derived from theposition in the tree. The tree has a variable depth. A node doesn’t havechildren if the complexity of the data in the associated tile is belowa threshold. This threshold is based on a combination of number offeatures, attributes, and vertices.
- tile_sprite(out_format:str='sprite.json')→dict
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:int,row:int,column:int)→str
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 arereturned 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 tilebelongs to.
column
Required string. Number of the column that tilebelongs to.
- Returns:
Bytes in PBF format
VectorTileLayerManager
- classarcgis.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 beapplied 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:str)→dict
The cancel operation supports cancelling a job while updatetiles is running from a hosted feature service. The result of thisoperation is a response indicating success or failure with errorcode and description.
- delete_job(job_id:str)→dict
This operation deletes the specified asynchronous job being run bythe geoprocessing service. If the current status of the job isSUBMITTED or EXECUTING, it will cancel the job. Regardless of status,it will remove all information about the job from the system. To cancel ajob 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 onlybe used for a Vector Tile Layer published from a service directory.- Returns:
A dictionary
# USAGE EXAMPLE>>>fromarcgis.layersimportVectorTileLayer>>>fromarcgis.gisimportGIS# 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:str|None=None,export_tiles_allowed:bool|None=None,min_scale:float|None=None,max_scale:float|None=None,max_export_tile_count:int|None=None,layers:list[dict]|None=None,cache_max_age:int|None=None,max_zoom:int|None=None)→dict
The edit operation enables editing many parameters in the service definition as well asthe 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 GeoWarehouseItem ID of the tile service.
export_tiles_allowed
Optional boolean.
exports_tiles_allowed
setsthe value to let users export tilesmin_scale
Optional float. Sets the services minimum scale forcaching. At the moment this parameter can only be set ifthe Vector Tile Layer was published through a service directory.
max_scale
Optional float. Sets the services maximum scale forcaching. At the moment this parameter can only be set ifthe Vector Tile Layer was published through a service directory.
max_export_tile_count
Optional int.
max_export_tile_count
sets themaximum amount of tiles to be exported from a singlecall.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 thisparameter can only be set if the Vector Tile Layer waspublished through a feature service.
max_zoom
Optional int. The maximum zoom level. At the moment thisparameter can only be set if the Vector Tile Layer waspublished through a feature service.
# USAGE EXAMPLE>>>fromarcgis.layersimportVectorTileLayer>>>fromarcgis.gisimportGIS# 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:str)→dict
The tile service job summary (jobs) resource represents asummary of all jobs associated with a vector tile service.Each job contains a jobid that corresponds to the specificjobid run and redirects you to the Job Statistics page.
- jobs()→dict
The tile service job summary (jobs) resource represents asummary of all jobs associated with a vector tile service.Each job contains a jobid that corresponds to the specificjobid run and redirects you to the Job Statistics page.
- rebuild_cache()
The rebuild_cache operation update the vector tile layer cache to reflectany changes made to the feature layer used to publish this vector tile layer.The results of the operation is a response indicating success, whichredirects you to the Job Statistics page, or failure.
- rerun_job(code,job_id:str)→dict
The
rerun_job
operation supports re-running a canceled job from ahosted map service. The result of this operation is a responseindicating success or failure with error code and description.Parameter
Description
code
required string, parameter used to re-run a givenjobs with a specific errorcode:
ALL|ERROR|CANCELED
job_id
required string, job to reprocess
- Returns:
A boolean or dictionary
- status()→dict
The status operation returns a dictionary indicatingwhether 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 VectorTile 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:bool=False)→dict
The update_tiles operation supports updating the cooking extent andcache levels in a Hosted Vector Tile Service. The results of theoperation is a response indicating success and a urlto the Job Statistics page, or failure.
It is recommended to use therebuild_cache method when your layer has beenpublished through a Feature Layer since edits require regeneration of the tiles.
Parameter
Description
merge_bundle
Optional bool. Default is False. This parameter willonly be set if the Vector Tile Layer has been publishedthrough a service directory.
- Returns:
Dictionary. If the product is not ArcGIS Online tile service, theresult will be None.
# USAGE EXAMPLE>>>fromarcgis.layersimportVectorTileLayer>>>fromarcgis.gisimportGIS# 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
- classarcgis.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 beapplied 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:str)
The changeProvider operation updates an individual service to useeither a dedicated or a shared instance type. When a qualified serviceis published, the service is automatically set to use shared instances.
When using this operation, services may populate other provider typesas values for the provider parameter, such as ArcObjects and SDS.While these are valid provider types, this operation does not supportchanging 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 eithera shared (“DMaps”) or dedicated (“ArcObjects11”) instancetype. These values are case sensitive.
- Returns:
Boolean
- delete()
This operation deletes an individual service, stopping the serviceand 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 theparameter service. You can leave out the serviceName and type parametersin the JSON representation. Any other properties that are left out are not persisted by the server.
Note
If the service is currently running you need to stop the service before editing it. This can be doneby calling the stop method on the service object. Once the service is stopped, you can edit the serviceand then start it again by calling the start method on the service object.
Parameter
Description
service_dictionary
Required dict. The JSON representation of the service and theproperties 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 reflectany changes made.The results of the operation is the url to the vector tile service once it isdone 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
- classarcgis.layers.CSVLayer(url_or_item:Item|str,gis:GIS|None=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.
- propertylatitude:str
The latitude field name. If not specified, the class will look forfollowing field names in the CSV source:
“lat”, “latitude”, “y”, “ycenter”, “latitude83”, “latdecdeg”, “POINT-Y”
- propertylongitude:str
The longitude field name. If not specified, theCSVLayer willlook for following field names in the CSV source:
“lon”, “lng”,”long”, “longitude”, “x”, “xcenter”, “longitude83”, “longdecdeg”, “POINT-X”
- propertyopacity:float
Get/Set the opacity value.
Parameter
Description
value
Required float. Value can range between 1 and 0, where 0 is 100percent transparent and 1 is completely opaque.
- Returns:
Float
- propertyrenderer:dict
Get/Set the Renderer of the CSV Layer
- Returns:
A
dict
like object used to update and alter JSON
- propertyscale
Gets/Sets the Min/Max Scale for the layer
Parameter
Description
value
Required tuple. (Min_value, Max_value)
- Returns:
A tuple (min, max)
- propertysql_expression:str
The SQL where clause used to filter features on the client. Onlythe features that satisfy the definition expression are displayedin the widget. Setting a definition expression is useful when thedataset is large and you don’t want to bring all features to theclient for analysis. Thesql_expressions may be set when alayer is constructed prior to it loading in the view or after ithas been loaded into the class.
- Returns:
String
GeoJSONLayer
- classarcgis.layers.GeoJSONLayer(url:str|None=None,data:str|dict|None=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 datastructures. The GeoJSON data must comply with the RFC 7946specification which states that the coordinates are inspatial 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.
- propertyopacity:float
Get/Set the opacity value.
Parameter
Description
value
Required float. Value can range between 1 and 0, where 0 is 100percent transparent and 1 is completely opaque.
- Returns:
Float
- propertyscale
Gets/Sets the Min/Max Scale for the layer
Parameter
Description
value
Required tuple. (Min_value, Max_value)
- Returns:
A tuple (min, max)
GeoRSSLayer
- classarcgis.layers.GeoRSSLayer(url:str,**kwargs)
Bases:
BaseOGC
The GeoRSSLayer class is used to create a layer based on GeoRSS. GeoRSS is away to add geographic information to an RSS feed. The GeoRSSLayer supportsboth GeoRSS-Simple and GeoRSS GML encodings, and multiple geometry types.
It exports custom RSS tags as additional attribute fields in the form ofsimple strings or an array of JSON objects.
Parameter
Description
url
Required String. The URL of the GeoRSS service.
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.
- propertyline_symbol:dict
Gets/Sets the Line Symbol for Polyline Geometries
- Returns:
InsensitiveDict
: A case-insensitivedict
like object used to update and alter JSONA variants of a case-less dictionary that allows for dot and bracket notation.
- propertyopacity:float
Get/Set the opacity value.
Parameter
Description
value
Required float. Value can range between 1 and 0, where 0 is 100percent transparent and 1 is completely opaque.
- Returns:
Float
- propertypoint_symbol:dict
Gets/Sets the Point Symbol for Point Geometries
- Returns:
A
dict
object used to update and alter JSON
- propertypolygon_symbol:dict
Gets/Sets the Polygon Symbol for Polygon Geometries
- Returns:
InsensitiveDict
: A case-insensitivedict
like object used to update and alter JSONA variants of a case-less dictionary that allows for dot and bracket notation.
OGCFeatureService
- classarcgis.layers.OGCFeatureService(url:str,gis: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.- propertycollections:Iterator[OGCCollection]
Yields all the OGC Feature Service Layers within the service.
- Returns:
Iterator[
OGCCollection
]
OGCCollection
- classarcgis.layers.OGCCollection(url:str,gis: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:int)→Dict[str,Any]
Gets an individual feature on the service. Needs to correspondto an id of the feature.
- Returns:
Dict[str, Any]
- query(query:str|None=None,limit:int=10000,bbox:list[float]|None=None,bbox_sr:int|None=None,time_filter:str|None=None,return_all:bool=False,**kwargs)→dict[str,Any]|DataFrame
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
- classarcgis.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 is1.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.
- propertylayers:list
Returns all layers from the WMS service, excluding the top-level group layer if present.
- propertyopacity:float
Get/Set the opacity value.
Parameter
Description
value
Required float. Value can range between 1 and 0, where 0 is 100percent transparent and 1 is completely opaque.
- Returns:
Float
- propertyproperties:dict
Returns the properties of the Layer, including sublayers if present.
- Returns:
dict
WMTSLayer
- classarcgis.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 is1.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.
- propertyopacity:float
Get/Set the opacity value.
Parameter
Description
value
Required float. Value can range between 1 and 0, where 0 is 100percent transparent and 1 is completely opaque.
- Returns:
Float
- operational_layer_json(identifier:str)→dict
Represents the JSON Format for the specified layer.
Parameter
Description
identifier
Required string. The layer’s Identifier to get the JSON format for.
You can find this by looping through the layers in theproperties attribute.
- for lyr in wmts.properties[“Capabilities”][“Contents”][“Layer”]:
print(lyr[“Identifier”])
- Returns:
dict
Utility Functions for Mapping
sync_navigation
- arcgis.map.Map.sync_navigation(self,map:Map|list[Map])→None
The
sync_navigation
method synchronizes the navigation from one rendered Map toanother rendered Map instance so panning/zooming/navigating in one will update the other.Note
Users can sync more than two instances together by passing in a list of Map instances tosync. The syncing will be remembered
Parameter
Description
map
Either a single Map instance, or a list of
Map
instances to synchronize to.
- arcgis.map.Map.print(self,file_format:str,extent:dict[str,Any],dpi:int=92,output_dimensions:tuple[float]=(500,500),scale:float|None=None,rotation:float|None=None,spatial_reference:dict[str,Any]|None=None,layout_template:str='MAP_ONLY',time_extent:tuple[int]|list[int]|None=None,layout_options:dict[str,Any]|None=None)→str
The
print
method prints theMap
object to a printable file such as a PDF, PNG32, JPG.Note
The render and print operations happenserver side (ArcGIS Online or Enterprise) and not on the client.
The
print
method takes the state oftheMap
, renders and returns either a page layout or a map without page surrounds of the specified extentin raster or vector format.Parameter
Description
file_format
Required String. Specifies the output file format. Valid types:
PNG8
|PNG32
|JPG
|GIF
|PDF
|EPS
|SVG
|SVGZ
.extent
Required Dictionary. Specify the extent to be printed.
# Example Usage:>>>extent={'spatialReference':{'latestWkid':3857,'wkid':102100},'xmin':-15199645.40582486,'ymin':3395607.5273594954,'xmax':-11354557.134968376,'ymax':5352395.451459487}
The spatial reference of the extent object is optional; when it isnot provided, it is assumed to be in the map’s spatial reference.When the aspect ratio of the map extent is different than the sizeof the map on the output page or the
output_dimensions
,you might notice more features on the output map.dpi
Optional integer. Specify the print resolution of the output file.
dpi
stands fordots per inch. A higher number implies better resolution and alarger file size.output_dimensions
Optional tuple. Specify the dimensions of the output file in pixels. If the
layout_template
is notMAP_ONLY
, the specific layouttemplate chosen takes precedence over this parameter.scale
Optional float. Specify the map scale to be printed. The map scale at which youwant your map to be printed. This parameter is optional butrecommended for optimal results. The
scale
property isespecially useful when map services in the web map havescale-dependent layers or reference scales set. Since the map thatyou are viewing on the web app may be smaller than the size of theoutput map (for example, 8.5 x 11 in. or A4 size), the scale of theoutput map will be different and you could see differences infeatures and/or symbols in the web application as compared withthe output map.When scale is used, it takes precedence over the extent, but theoutput map is drawn at the requested scale centered on the centerof the extent.
rotation
Optional float. Specify the number of degrees by which the map frame will berotated, measured counterclockwise from the north. To rotateclockwise, use a negative value.
spatial_reference
Optional Dictionary.Specify the spatial reference in which map should be printed. Whennot specified, the following is the order of precedence:
read from the
extent
parameterread from the base map layer of your web map
read from the
layout_template
chosen
layout_template
Optional String. The default value
MAP_ONLY
does not use any template.time_extent
Optional List . If there is a time-aware layer and you want itto be drawn at a specified time, specify this property. This orderlist can have one or two elements. Add two elements (
startTime
followed byendTime
) to represent a time extent, or provideonly one time element to represent a time instant.Times are always in UTC.# Example Usage to represent Tues. Jan 1, 2008 00:00:00 UTC:# to Thurs. Jan 1, 2009 00:00:00 UTC.>>>time_extent=[1199145600000,1230768000000]
layout_options
Optional Dictionary. This defines settings for different available page layout elementsand is only needed when an available
layout_template
is chosen.Page layout elements includetitle
,copyrighttext
,scalebar
,authorname
, andcustomtextelements
.For more details, seeExportWebMap specification.- Returns:
A URL to the file which can be downloaded and printed.
# USAGE EXAMPLE 1: Printing a web map to a JPG file of desired extent.fromarcgis.mapimportMapfromarcgis.gisimportGIS# connect to your GIS and get the web map itemgis=GIS(url,username,password)wm_item=gis.content.get('1234abcd_web map item id')# create a WebMap object from the existing web map itemwm=Map(item=wm_item)# create an empty web mapwm2=Map()wm2.content.add(<desiredItemorLayerobject>)# set extentredlands_extent={'spatialReference':{'latestWkid':3857,'wkid':102100},'xmin':-13074746.000753032,'ymin':4020957.451106308,'xmax':-13014666.49652086,'ymax':4051532.26242039}# printprinted_file_url=wm.print(file_format='JPG',extent=redlands_extent)printed_file2_url=wm2.print(file_format='PNG32',extent=redlands_extent)# Display the result in a notebook:fromIPython.displayimportImageImage(printed_file_url)# Download file to diskimportrequestswithrequests.get(printed_file_url)asresp:withopen('./output_file.png','wb')asfile_handle:file_handle.write(resp.content)
SymbolService
- classarcgis.layers._vtl._vector_tile_layers.SymbolService(url:str,gis:GIS=None)
Bases:
object
Symbol service is an ArcGIS Server utility service that provides accessto operations to build and generate images for Esri symbols to beconsumed by internal and external web applications.
- generate_image(item:Item,name:str|None=None,dict_features:dict[str,Any]|None=None,size:str='200,200',scale:float=1,anchor:bool=False,image_format:str='png',dpi:int=96,file_path:str|Path=None)→str
Returns a single symbol based on a web style item.
Parameter
Description
item
Required Item. The web style ArcGIS Enterprise portal item ID. The web style must belong to the same organizationthe ArcGIS Server is federated to.
name
Optional String. The web style ArcGIS Enterprise portal item ID. The web style must belong to the same organizationthe ArcGIS Server is federated to.
dict_features
Optional dict[str, Any]. The attributes and configuration key and value pairs for dictionary-based styles.
size
Optional String. The size (width and height) of the exported image in pixels. If the size is not specified, theimage will be constrained by the requested symbol’s size.
scale
Optional Float. A value of 1.0 implies the symbol is not scaled. Setting the value to 1.5 scales the image to 50percent more than the image’s original size. Settings the value to 0.5 reduces the image’s original size by 50percent.If both the size and scale parameters are specified, both changes will be honored; the symbol will be scaled to thevalue set for scale and resized to the value set for the size parameter.
anchor
Optional Bool. The symbol placement in the image. When set to true, the original symbol anchor point placement inthe image is honored. When set to false, the symbol is centered to the image. Having the image centered can beuseful if you want to preview the whole symbol without taking symbol offset or anchor points into account. Thedefault value is false.
image_format
Optional String. The output image format. The default format is png. The allowed values are: png, png8, png24,png32, jpg, bmp, gif, svg, and svgz.
dpi
Optional Int. The device resolution of the exported image (dots per inch). If the dpi value is not specified, animage with a default DPI of 96 will be exported.
file_path
Optional String | pathlib.Path. The full save path with the file name to the save location. The folder must exist.
- Returns:
String