2

I want to use arcpy.Project_management to project my data.

I have....

arcpy.env.workspace = scratchGDB

fcList = arcpy.ListFeatureClasses()
for fc in fcList:
    print fc

>>> 
lease90
lease180

When I add the projection I get 'ExecuteError: ERROR 000210: Cannot create output'....

arcpy.env.workspace = scratchGDB

fcList = arcpy.ListFeatureClasses()
for fc in fcList:
    print fc
    WGS84aux = arcpy.SpatialReference(3857)
    arcpy.Project_management(fc, fc+ '_WGS84aux', WGS84aux)

Suggestions?

enter image description here

UPDATE:

I added a feature class to feature class and commented the projection out for test purposes -- the feature class to feature class worked. However, project still does not work.

arcpy.env.workspace = scratchGDB

fcList = arcpy.ListFeatureClasses()
for fc in fcList:
    print fc
    WGS84aux = arcpy.SpatialReference(3857)
    arcpy.FeatureClassToFeatureClass_conversion(fc, scratchGDB, fc + '_test')
    ##arcpy.Project_management(fc, fc+ '_WGS84aux', WGS84aux)

enter image description here

I've also projected manually and it works - I am so lost.

enter image description here

  • Do the input feature classes have a projection defined? Does the gdb have a projection set restricting it to a certain projection? – jbchurchill Nov 22 '16 at 17:06
  • 2
    CurrentWorkspace should be supported with Project, but maybe be more explicit as a test? Add import os and change the output FC name to: os.path.join(scratchGDB, fc + '_WGS84aux') – KHibma Nov 22 '16 at 17:09
  • The input feature class projection is GCS_WGS_1984, and I need it in WGS_1984_Web_Mercator_Auxiliary_Sphere. There is not a restriction on the scratchGDB. – a1234 Nov 22 '16 at 17:10
  • @KHibma Tried - still does not work. – a1234 Nov 22 '16 at 17:28
  • maybe change your spatial reference variable name to cs and try it... – ziggy Nov 22 '16 at 18:19
1

I am unable to reproduce this.

The test, which creates test data first, that I ran using ArcGIS 10.4.1 for Desktop on a local file geodatabase was:

import arcpy

if arcpy.Exists(r"C:\Temp\test.gdb"):
    arcpy.Delete_management(r"C:\Temp\test.gdb")  

arcpy.CreateFileGDB_management(out_folder_path="C:/Temp",
                               out_name="test",
                               out_version="CURRENT")
arcpy.CreateFishnet_management(out_feature_class="C:/Temp/test.gdb/testFC",
                               origin_coord="0 0",
                               y_axis_coord="0 1",
                               cell_width="1", cell_height="1",
                               number_rows="1", number_columns="1",
                               corner_coord="", labels="NO_LABELS",
                               template="DEFAULT", geometry_type="POLYGON")
arcpy.DefineProjection_management(in_dataset="C:/Temp/test.gdb/testFC",
                                  coor_system="GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]")

arcpy.env.workspace = r"C:\Temp\test.gdb"

fcList = arcpy.ListFeatureClasses()
print fcList
for fc in fcList:
    print fc
    WGS84aux = arcpy.SpatialReference(3857)
    arcpy.Project_management(fc, fc+ '_WGS84aux', WGS84aux)
print arcpy.ListFeatureClasses()

The output was observed to be as expected:

>>> 
[u'testFC']
testFC
[u'testFC', u'testFC_WGS84aux']
>>> 
0

I had to explicitly assign a variable to os.path.join(scratchGDB, fc). I don't understand why this would be needed if the environment workspace is set the the scratchGDB, but it worked.

arcpy.env.workspace = scratchGDB

fcList = arcpy.ListFeatureClasses()
for fc in fcList:
    fcfull = os.path.join(scratchGDB, fc)
    WGS84aux = arcpy.SpatialReference(3857)
    projected = fcfull + 'WGSaux84'
    arcpy.Project_management(fcfull, projected, WGS84aux)

Your Answer

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.