Replace Web Layer (Server)

Summary

Replaces the content of a web layer in a portal with the content of another web layer.

Usage

  • The target layer is the web layer to be replaced. The update layer is the replacement web layer. The target and update layers can be the following types of web layers:

    • Vector tile layers
    • Tile layers
    • Scene layers published from one of the following sources:
      • Scene layer packages hosted on ArcGIS Online or an ArcGIS Enterprise portal
      • Referenced scene caches in folder or cloud data stores
      Note:

      Voxel scene layers cannot be replaced.

  • To replace a vector tile layer on an ArcGIS Enterprise portal, you must be using version 10.6 or later. To replace a tile layer, you must be using version 10.8 or later. To replace a scene layer, you must be using version 10.8.1 or later.

  • Your ArcGIS Pro active portal must be the portal that hosts the target and update layers. You must be signed in to ArcGIS Pro with the account that owns the target and update layers.

  • The target and update layers must be of the same type. For example, you cannot replace a vector tile layer with a tile layer.

  • The scene layer type of the target layer and update layer must match. For example, you cannot replace a building scene layer with a 3D object scene layer.

  • To replace a web scene layer, the target layer and update layer must be published from the same source. For example, you cannot replace a web scene layer published from a scene layer package with a web scene layer published from a referenced scene cache.

  • To replace web scene layers published from referenced scene caches, the scene services of the target layer and update layer must exist in the same server and server folder.

  • When the target layer is updated, the content of the layer is replaced. The item ID and service URL of the target layer do not change.

  • The web layer that is replaced is not overwritten. Instead, it is archived in your portal with a new name. By default, the archive layer name is <layer name>_archive_<timestamp>. You can assign a different name, but it must be a unique web layer name in the portal.

  • By default, the archive layer uses the item ID of the update layer. Optionally, you can specify a new item ID for the archive layer.

  • Optionally, you can replace the item information of the target layer with the item information of the update layer. If you replace the item information, the summary, description, tags, and thumbnail image are replaced. Other information, such as the credits (attribution) and terms of use are not replaced.

Parameters

LabelExplanationData Type
Target Layer

The web layer to be replaced. In addition to a layer or catalog path, it can also be specified using the item ID or service URL of one of the following:

  • Vector tile
  • Tile layer
  • Scene layer published from one of the following sources:
    • Scene layer package
    • Referenced scene cache in folder or cloud data stores

Vector Tile Layer; Internet Tiled Layer; Scene Layer
Archive Layer Name

A unique name for the archive layer. The web layer that is replaced remains in the portal as an archive layer.

String
Update Layer

The replacement web layer. In addition to a layer or catalog path, it can also be specified using the item ID or service URL of one of the following:

  • Vector tile
  • Tile layer
  • Scene layer published from one of the following sources:
    • Scene layer package
    • Referenced scene cache in folder or cloud data stores

Vector Tile Layer; Internet Tiled Layer; Scene Layer
Replace Item Information
(Optional)

Specifies whether the thumbnail image, summary, description, and tags will be replaced. In either case, the item's credits (attribution), terms of use, and created from information are not replaced.

  • Unchecked—The target layer's item information will not be replaced when the layer is updated. This is the default.
  • Checked—The target layer's item information will be replaced by the update layer's item information.
Boolean
Create New Item For Archive Layer
(Optional)

Specifies whether an item will be created for the archive layer. This option is supported on portals in ArcGIS Online and ArcGIS Enterprise 10.8 or later.

  • Unchecked—The item ID of the update layer will be used for the archive layer. This is the default for vector tile layers and tile layers.
  • Checked—An item ID will be created for the archive layer. This is the default for scene layers.
Boolean

Derived Output

LabelExplanationData Type
Updated Target Layer

The URL of the updated web layer.

String

arcpy.server.ReplaceWebLayer(target_layer, archive_layer_name, update_layer, {replace_item_info}, {create_new_item})
NameExplanationData Type
target_layer

The web layer to be replaced. In addition to a layer or catalog path, it can also be specified using the item ID or service URL of one of the following:

  • Vector tile
  • Tile layer
  • Scene layer published from one of the following sources:
    • Scene layer package
    • Referenced scene cache in folder or cloud data stores

Vector Tile Layer; Internet Tiled Layer; Scene Layer
archive_layer_name

A unique name for the archive layer. The web layer that is replaced remains in the portal as an archive layer.

String
update_layer

The replacement web layer. In addition to a layer or catalog path, it can also be specified using the item ID or service URL of one of the following:

  • Vector tile
  • Tile layer
  • Scene layer published from one of the following sources:
    • Scene layer package
    • Referenced scene cache in folder or cloud data stores

Vector Tile Layer; Internet Tiled Layer; Scene Layer
replace_item_info
(Optional)

Specifies whether the thumbnail image, summary, description, and tags will be replaced. In either case, the item's credits (attribution), terms of use, and created from information are not replaced.

  • KEEPThe target layer's item information will not be replaced when the layer is updated. This is the default.
  • REPLACEThe target layer's item information will be replaced by the update layer's item information.
Boolean
create_new_item
(Optional)

Specifies whether an item will be created for the archive layer. This option is supported on portals in ArcGIS Online and ArcGIS Enterprise 10.8 or later.

  • TRUEAn item ID will be created for the archive layer. This is the default for scene layers.
  • FALSEThe item ID of the update layer will be used for the archive layer. This is the default for vector tile layers and tile layers.
Boolean

Derived Output

NameExplanationData Type
updated_target_layer

The URL of the updated web layer.

String

Code sample

ReplaceWebLayer example 1 (stand-alone script)

The following script replaces a web layer using the item IDs of the input layers.

import arcpy
import time

# Set local variables
targetLayerID = "42994b1a3e63425aa02bcfa1200683ae"
archiveLayerName = "ReplaceWebLayerExample_archive_" + time.strftime("%Y%m%d")
updateLayerID = "9e1d80c874e040fc88ad06b0cfa01381"
replaceItemInfo = "REPLACE"
createNewItem = "TRUE"

# Run Replace Web Layer
arcpy.server.ReplaceWebLayer(targetLayerID, archiveLayerName, updateLayerID, 
                             replaceItemInfo, createNewItem)

print("Successfully replaced web layer.")
ReplaceWebLayer example 2 (stand-alone script)

The following script replaces a web layer on ArcGIS Enterprise using the service URLs of the input layers.

import arcpy
import time

# Set local variables
targetLayer = "https://webadaptorhost.domain.com/webadaptorname/rest/services/Hosted/targetServiceName/VectorTileServer"
archiveLayerName = "targetServiceName_archive_" + time.strftime("%Y%m%d")
updateLayer = "https://webadaptorhost.domain.com/webadaptorname/rest/services/Hosted/updateServiceName/VectorTileServer"

# Run Replace Web Layer
arcpy.server.ReplaceWebLayer(targetLayer, archiveLayerName, updateLayer)

print("Successfully replaced web layer.")

Environments

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes

Related topics