HOW TO
Branch versioning is a type of geodatabase versioning that works with the ArcGIS Enterprise Web GIS model using a services-based architecture to allow multiuser editing workflows and long transaction scenarios through web feature layers. Web feature layers (also known as feature services) are layers that are shared to support displaying, querying, and editing data on the web.
The ArcGIS API for Python makes programmatic editing of branch-versioned feature layers possible. At a high level, a typical branch versioned editing workflow is as follows:
The below Python code snippet demonstrates how to perform edits on a branch versioned point feature layer via the Version Management Server
from arcgis.gis import GIS
from arcgis.features._version import VersionManager
try:
# parameters
machine = 'machine.domain'
portalUrl = 'https://{0}/webadaptor'.format(machine)
base_server_url = "https://{0}/server/rest/services/samplePointsBV".format(machine)
version_management_server_url = "{0}/VersionManagementServer".format(base_server_url)
new_version_name = "v1"
userName = ''
password = ''
# Sign in to Portal
gis = GIS(portalUrl, userName, password)
vms = VersionManager(version_management_server_url, gis)
print(vms.properties)
# Get a list of all versions
versions = vms.all
print(versions)
# feature to add
feature = {
"attributes": {
"name": "TEST123",
},
"geometry": {
"x": 153.11349,
"y": -27.492016
}
}
# Create a new version
version = vms.create(new_version_name)
print(version.properties)
# Get the layer to edit
editlayer = version.layers[0]
print(editlayer)
# Start an edit session
version.mode = 'edit'
version.start_editing()
add_result = version.edit(editlayer, adds=[feature], updates=None, deletes=None, use_global_ids=False, rollback_on_failure=True)
print(add_result)
version.stop_editing(save=True)
version.mode = None
print("Edits complete")
except Exception as err:
print("Error: {0}".format(err))
Get help from ArcGIS experts
Download the Esri Support App