Custom Editor widget to copy/paste geometry between feature services?

5046
19
03-18-2016 09:32 AM
CoryCampbell1
New Contributor III

DOES IT EXIST

Has anyone already developed a custom Editor widget that includes functionality (GUI tools) to select one or more features (geometries) from one map/feature service and paste it into another feature service? For example, I don't want users to digitize polygon boundaries if those boundaries are available from another hosted service. Preferably the widget could be used with Web AppBuilder. Ideally, attributes would also copy over provided the field names/types are identical.

IF NOT, WHY NOT

This seems like functionality that would be in high demand, but it doesn't already exist in the Web AppBuilder Editor widget - so what are the limitations/constraints to including this kind of functionality? I've read several older posts for people customizing this functionality, and the API4JS docs seem to indicate that it's doable via cloning. Is it too difficult to allow configuration with template pickers, graphics and/or event layers, projection problems, client memory limits, read permissions limits, or something else?

19 Replies
StephNelson1
New Contributor

Has anyone gotten back to you? I have the same need and similar thoughts on this topic!

0 Kudos
GordonTyler
New Contributor II

We have the same need and we have come up with a workaround using the GeoProcessing widget.

Create a GP tool (based on a python script) which takes a user selected polygon feature as input and copies the feature to another feature class (in our case the feature class is in an enterprise GDB underpinning another WFS in the same webapp).

Publish the GP tool and set up the GeoProcessing widget within the webapp.

Within WAB (at v2.4 - not sure about earlier versions) when you click a polygon feature and then click the three dots at the bottom right of the pop-up you get a menu option to set it as the input to the GeoProcessing widget task.

It's not pretty but it works for us internally. Not sure if it would be as easy in ArcGIS Online.

You can handle the attributes copying over in the Python script or having the user enter them in the widget dialogue.

I agree that a simple copy-paste of a feature/geometry (like you can do in Desktop) is highly desirable!

AhnaMiller2
Occasional Contributor

Hey Gordon, 

Your GP tool from a python script sounds like a good work around in the meantime to this issue.I am working on something similar but instead of pasting into a different feature class, it will be pasting into the same feature class.  Any chance you are able to share your code to work off of? 

0 Kudos
GordonTyler
New Contributor II

Hi Ahna,

Sure, here is a cut down version which shows what my script does in simple terms. It should work for features in the same feature class. It includes the edits made ('esri added') when the tool is published.

import sys, os, arcpy

# Esri start of added variables
g_ESRI_variable_1 = os.path.join(arcpy.env.packageWorkspace,u'\\\\<server>\\arcgissystem\\arcgisinput\\<tool>.GPServer\\extracted\\v101\\<connection>.sde')
# Esri end of added variables

#input variables
featSet = arcpy.GetParameter(0) #feature selected within app to be copied
Attribute1 = sys.argv[2] #user entered attribute value if needed

OutputWS = g_ESRI_variable_1
OutputFeatures = os.path.join(OutputWS, "<OUtput Feature Class>")

sr = arcpy.SpatialReference(27700) #spatial ref for geometry

sc = arcpy.SearchCursor(featSet,"",sr,"","")
rowIn = sc.next() # this script assumes only a single feature is being copied

#write the feature to the output
rowsOut = arcpy.InsertCursor(OutputFeatures)
rowOut = rowsOut.newRow()

#Copy geometry
rowOut.setValue("SHAPE", rowIn.getValue("SHAPE"))

#Copy attributes
rowOut.setValue("ATTRIBUTE", rowIn.getValue("ATTRIBUTE"))

#User entered attributes for new feature if needed
rowOut.setValue("ATTRIBUTE1", Attribute1)
rowsOut.insertRow(rowOut)

del rowsOut
del sc
AhnaMiller2
Occasional Contributor

Thank you SO much Gordon! 

0 Kudos
AmberKelly
New Contributor III

Hi Gordon,

Just wondering if you still have the original py script for the GP tool you created and would be willing to hare? My organisation also needs to copy polygons (parcels in this instance) and paste into a separate existing layer all from within Web App Builder. 

Any help would be great!

Amber

0 Kudos
GordonTyler
New Contributor II

Hi Amber,

The script shared above in my earlier reply is the same as my original except with attribute names replaced and server names taken out. I can't share the original unfortunately.

Is there a specific bit you're having trouble with?

Gordon

0 Kudos
AmberKelly
New Contributor III

Hi Gordon,

I must have misunderstood the original post, I thought you had originally created a script to copy from one feature class and paste into a different editable feature class but the one you have uploaded is for copying from and pasting into the same feature class. Does this script cover both of these scenarios? I am very much in the learning phase in regards to Python so apologies for my ignorance!

Cheers

Amber

0 Kudos
AhnaMiller2
Occasional Contributor

Hi Amber, I did this just recently. I can reach out to you tomorrow with a sample of how this can be done

0 Kudos