0

I am trying to export/copy a feature service to a local geodatabase where I can work on it locally.

I have provided the code below. I keep getting an "Object: Error in executing tool" for the last line where I am trying to copy the feature.

from arcgis.gis import GIS
from arcgis.features.use_proximity import create_buffers

import arcpy

#########################################################################################

GDB_Name = input("Name Geodatabase")

Folder_Input = input("Provide Folder Path of Project")

Item_ID = input("Provide item ID")


#########################################################################################

gis = GIS("http://arcgis.com", "XXXXXXXX", "XXXXXXXXXXX")

search_results = gis.content.search('{}'.format(Item_ID))

Trail_Data = search_results[0]

WorkspaceGDB = arcpy.CreateFileGDB_management(Folder_Input, '{}.gdb'.format(GDB_Name))
print("GDB created")

arcpy.env.workspace = r'{}'.format(WorkspaceGDB)

arcpy.CopyFeatures(Trail_Data, "Area_Trail_Data")
New contributor
P. Shutler is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • 1
    Simply, your Trial_Data is a pointer to an ArcGIS Python API item. This is not valid input to the CopyFeatures tool. You're on the right track, but this workflow, as-is will not work without coming at this from another angle. – KHibma Aug 13 at 14:58
  • I'm going to try and download the "searched item" as a shapefile, then locate the newly downloaded shapefile, and try to copy from there. I will update the post if this workflow works. – P. Shutler Aug 13 at 18:55
0

Using your Trail_Data variable:

# select all features
query = Trail_Data.query(where='1=1')

# save selected features to specified geodatabase
query.save("path_to_geodatabase", "new_feature_class_name")

I am constantly confused by the ArcGIS API for Python, but from what I gather, your Trail_Data variable is a Feature Collection and the query result is a Feature Set. The Feature Set can be saved directly to a file geodatabase.

Your Answer

P. Shutler is a new contributor. Be nice, and check out our Code of Conduct.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.