Select to view content in your preferred language

arcgis pro paste special from query layer fail

353
4
05-28-2024 09:18 AM
AmeWunderle
New Contributor III

I have a query layer that I am able to use in ArcMap to copy and paste features from easily. Select feature, paste to editable layer with same geometry. Easy peasy.

In pro, not so much. I am able to copy/paste from the original base feature class in the enterprise geodatabase, but not any query layers I created from that (also housed in the enterprise geodatabase). The shape/geometry and objectid are the same for the query layers as the original features but whether I create the query layer in pro or create use the version I created for ArcMap I get the same behaviour.

I can select the feature in the map, right click-choose copy. Go to the paste button and select paste special. I get the dialog box and can select my editable layer it should go in and then I get the Failed dialog box. If I do the same workflow with the original feature class (not query layer) it works fine. I can copy/paste from ArcMap using the query layer without any issue. As a side note, I can select, export easily from these query layers in pro. 

Is there another work around here? I need the query layers as they enrich the data and help determine which features should be selected/copied. 

0 Kudos
4 Replies
Matthew_Muehlhauser
New Contributor III

I'm not quite sure why it doesn't work, but there's a decently quick way you can do it with Python. If you've already made your selection in the map, then you can run the below code in the python console. Of course, you'll need to fill in the "NAME_OF_LAYER", "PATH_TO_DATA", and the fields array (replacing FLD1 and FLD2 if you want any other fields, you can just remove them if not), but the rest should work. For the out_fc, you can just drag the feature from the catalog to the console and it should put the path formatted properly.

 

project = arcpy.mp.ArcGISProject("CURRENT")
mv = project.activeMap
lyr = mv.listLayers("NAME_OF_LAYER")[0]
out_fc = "PATH_TO_DATA"

fields = ["SHAPE@", "FLD1", "FLD2"]

features = [list(ftr) for ftr in arcpy.da.SearchCursor(lyr, fields)]
with arcpy.da.InsertCursor(out_fc, fields) as cursor:
  for ftr in features:
    cursor.insertRow(ftr)

 

If you've already run it once and it works, then you can re-run it in the same Pro session by just running the last 4 lines.

You can also run something to get all the fields, but I'm not sure if you're actually keeping all the fields or just a subset. You would also have to rename the Shape field to SHAPE@ and the objectid field to OID@ to be sure there aren't any issues.

 

fields = [fld.name for fld in arcpy.ListFields(lyr)]

 

0 Kudos
AmeWunderle
New Contributor III

Thanks Matthew,

I can append the features using the Append tool or export them easily. Just the only tool/buttons I can't use is the Copy/Paste Special buttons for any query layer I make. The data is also selectable and you can navigate to features etc. Everything but the Copy/Paste is working. I've been using the append tool as its quick when I need to, but its nice to be able to copy/paste a feature from our enterprise database into another layer especially if its only one or two features.

0 Kudos
Bud
by
Honored Contributor

You could submit a case to Esri Support or submit an Idea in the ArcGIS Pro Ideas page.

0 Kudos
Scott_Harris
Esri Regular Contributor

@AmeWunderle this will be possible in the next release of ArcGIS Pro. Thank you!

0 Kudos