Feature Layer properties

Hosted Feature services, also called hosted feature layers, can contain one or more feature layers with spatial information, or one or more tables that do not have spatial information. They also contain many properties that inform client applications about their state, version, capabilities, extent, allowed operations and much more. Together these properties make up a service or layer definition. Refer to the feature service page to learn about these types of services in detail. This guide outlines how you can query and update feature service properties using the item sourced by this feature service.

NOTE: You must be the item owner, an organization administrator, or an user assigned a role with the appropriate privileges to run the update_definition() method used in this guide.

Connect to a Web GIS and retrieve a Feature Layer item

# connect to your GIS with publisher or higher privileges
from arcgis.gis import GIS
gis = GIS(profile='layer_owner')
search_result= gis.content.search("Ports along west coast", "Feature Layer")
ports_item = search_result[0]
ports_item
Ports along the US West Coast
Locations of various ports along the West Coast of the United States.Feature Layer Collection by api_data_owner
Last Modified: July 18, 2023
0 comments, 3 views

The feature service definition

Once you have a Feature Layer item, you can access the definition of the feature service that sources the item. First, import the FeatureLayerCollection class. This class contains a method called fromitem(), which returns an instance of a FeatureLayerCollection object.

from arcgis.features import FeatureLayerCollection
ports_flc = FeatureLayerCollection.fromitem(ports_item)

Querying the properties property on this FeatureLayerCollection object returns a dictionary of all the feature service properties. Let's inspect if the description or copyright attributes of the service have been entered.

ports_flc.properties
{
  "currentVersion": 11.1,
  "serviceItemId": "e0dae2efe40a414a9700bee3a35c846b",
  "serviceDescription": "",
  "hasVersionedData": false,
  "supportsDisconnectedEditing": false,
  "hasStaticData": false,
  "hasSharedDomains": false,
  "maxRecordCount": 1000,
  "supportedQueryFormats": "JSON",
  "supportsVCSProjection": false,
  "supportedExportFormats": "csv,shapefile,sqlite,geoPackage,filegdb,featureCollection,geojson,excel",
  "capabilities": "Create,Delete,Query,Update,Editing,Sync",
  "description": "",
  "copyrightText": "",
  "spatialReference": {
    "wkid": 102100,
    "latestWkid": 3857
  },
  "initialExtent": {
    "xmin": -17764735.368653413,
    "ymin": 2241467.1730974796,
    "xmax": -13044788.959018612,
    "ymax": 5721784.0173567245,
    "spatialReference": {
      "wkid": 102100,
      "latestWkid": 3857
    }
  },
  "fullExtent": {
    "xmin": -17764735.368653413,
    "ymin": 2241467.1730974796,
    "xmax": -13044788.959018612,
    "ymax": 5721784.0173567245,
    "spatialReference": {
      "wkid": 102100,
      "latestWkid": 3857
    }
  },
  "allowGeometryUpdates": true,
  "units": "esriMeters",
  "supportsAppend": true,
  "supportsSharedDomains": true,
  "supportsWebHooks": true,
  "supportsTemporalLayers": true,
  "layerOverridesEnabled": true,
  "size": 32768,
  "syncEnabled": true,
  "syncCapabilities": {
    "supportsAsync": true,
    "supportsRegisteringExistingData": true,
    "supportsSyncDirectionControl": true,
    "supportsPerLayerSync": true,
    "supportsPerReplicaSync": true,
    "supportsSyncModelNone": true,
    "supportsRollbackOnFailure": true,
    "supportsAttachmentsSyncDirection": true,
    "supportsBiDirectionalSyncForServer": true,
    "supportedSyncDataOptions": 4
  },
  "supportsApplyEditsWithGlobalIds": true,
  "supportsReturnDeleteResults": true,
  "supportsLayerOverrides": true,
  "supportsTilesAndBasicQueriesMode": true,
  "supportsQueryContingentValues": true,
  "supportedContingentValuesFormats": "JSON, PBF",
  "supportsContingentValuesJson": 2,
  "advancedEditingCapabilities": {
    "supportsSplit": false,
    "supportsReturnServiceEditsInSourceSR": false,
    "supportsAsyncApplyEdits": true,
    "supportsReturnEditResults": true,
    "supportsApplyEditsbyUploadID": true,
    "supportedApplyEditsUploadIDFormats": "JSON"
  },
  "editorTrackingInfo": {
    "enableEditorTracking": false,
    "enableOwnershipAccessControl": false,
    "allowOthersToQuery": true,
    "allowOthersToUpdate": true,
    "allowOthersToDelete": true,
    "allowAnonymousToQuery": true,
    "allowAnonymousToUpdate": true,
    "allowAnonymousToDelete": true
  },
  "xssPreventionInfo": {
    "xssPreventionEnabled": true,
    "xssPreventionRule": "InputOnly",
    "xssInputRule": "rejectInvalid"
  },
  "layers": [
    {
      "id": 0,
      "name": "Ports_along_the_US_West_Coast",
      "parentLayerId": -1,
      "defaultVisibility": true,
      "subLayerIds": null,
      "minScale": 73957191,
      "maxScale": 0,
      "type": "Feature Layer",
      "geometryType": "esriGeometryPoint"
    }
  ],
  "tables": []
}

Both properties are empty. Let's update them as an example of how to update feature service properties

Update the feature service definition

The manager property accesses the FeatureLayerCollectionManager class. Use the update_definition() method and pass in a dictionary of the properties you want to edit to update the definition of the hosted feature service.

Updating feature service properties

update_dict = {'description':'Updated using ArcGIS Python API',
              'copyrightText':'copyright Python API guide'}
ports_flc.manager.update_definition(update_dict)
{'success': True}

Let us access the service definition once again to see if these fields are updated

ports_flc.properties.description
'Updated using ArcGIS Python API'
ports_flc.properties.copyrightText
'copyright Python API guide'

Updating feature service capabilities

Let's edit the capabilities property to disable editing and sync

update_dict2 = {"capabilities": "Query",
               "syncEnabled": False}
ports_flc.manager.update_definition(update_dict2)
{'success': True}
ports_flc.properties.capabilities
'Query'
ports_flc.properties.syncEnabled
False
"syncCapabilities" in ports_flc.properties
False

Turning off syncEnabled automatically removes syncCapabilities.

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