1
import arcpy
import os
fc = []
walk = arcpy.da.Walk('C:/Wiley/P1/gis/OSM.gdb')
outdir = "C:/Wiley/P1/gis/HK80.gdb/osm"
for root, dirs, datasets in walk:
 for ds in datasets:
 fc.append(os.path.join(root, ds))
if fc:
 output = os.path.join(outdir, os.path.basename(ds) + "_project") 
 hkfc = "C:\Wiley\P1\gis\HK80.gdb\Building_merge_dissolved"
 # Describe the feature class and get its spatial reference
 desc = arcpy.Describe(hkfc)
 spatialRef = desc.spatialReference
 out_coordinate_system = arcpy.SpatialReference('spatialRef.name')
 arcpy.Project_management(fc, output, out_coordinate_system) 

I am sure with a trained eye you guys know what to do. It came back to me with the following error:

Runtime error Traceback (most recent call last): File "", line 21, in File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\arcobjects\mixins.py", line 962, in init self._arc_object.createFromFile(item) RuntimeError: ERROR 999999: Error executing function.

What went wrong?

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Sep 17, 2017 at 16:36

1 Answer 1

1

I assume you want to loop through all the feature classes you're collecting, so it should be:

# we only need to do this once
hkfc = "C:\Wiley\P1\gis\HK80.gdb\Building_merge_dissolved"
desc = arcpy.Describe(hkfc)
spatialRef = desc.spatialReference
for input in fc:
 output = os.path.join(outdir, os.path.basename(input) + "_project") 
 arcpy.Project_management(input, output, spatialRef) 

The way you're using walk is a little awkward but should be functional.

answered Sep 17, 2017 at 16:42
2
  • Thx for your answer!! I will try it tmr! Commented Sep 17, 2017 at 17:39
  • Alright I understand now. Always use the variables inside the for function. Commented Sep 18, 2017 at 7:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.