Copy a polygon from one feature layer to another one in Portal

04-09-2018 10:22 PM
New Contributor III


I would like to copy a polygon from one feature layer to another one in a web application in Portal for ArcGIS containing both polygon layers. I have a federated ArcGIS for Server, to which I have published a geoprocessing service with the following code in it:  

import arcpy

inPolygon = arcpy.GetParameter(0)
copyLayer = arcpy.GetParameter(1)

with arcpy.da.InsertCursor(copyLayer, ['PIN','SHAPE@']) as icursor:
with arcpy.da.SearchCursor (inPolygon, ['PIN','SHAPE@']) as cursor:
for row in cursor:

So I have a layer going in for which I create a search cursor, with the resulting rows copied to another layer with an insert cursor.  This works fine on the desktop. When I publish the geoprocessing service in ArcGIS for Server, I make the layers interactive so that the user can choose the input and output layers. Indeed, In Portal this works and I can let the user select these layers. Note that both layers in Portal for ArcGIS are the same type (polygon) and both have an attribute field named "PIN".

However the copying does not work. I have also tried using the "select" widget to select one polygon of the input layer as well then redirect that input to the geoprocessing service, but nothing works.  The error I am getting in ArcGIS for Server logs is "The workspace is not connected". 

Does anyone has an example of how to copy a polygon feature from one feature layer to another in Portal for ArcGIS using a geoprocessing service? 



0 Kudos
1 Reply
Esri Notable Contributor

Are these hosted feature layers? You can try to do this in ArcMap using the disconnected editing workflow:

Making a local copy of a feature service for editing—Help | ArcGIS Desktop 

Another approach is to get the input features through the input parameter, and then use Add/Update/Delete operations within the API to update the new layer. You're not getting a feature class, layer, table, or table view when you run it as a GP service, so an insert cursor won't work.

InsertCursor—Data Access module | ArcGIS Desktop 

ParameterExplanationData Type

The feature class, layer, table, or table view.

0 Kudos