6

I'm trying to change the coordinate system of a batch of feature classes to 'Geodetic datum GDA94(code=4283) using Define Projection. I receive no python error message and no change to the coordinate system, just lists returned from ListFeatureClasses and ListWorkspaces. My code is below. Can someone suggest why Define Projection isn't converting the data it receives?

import arcpy
from arcpy import env
import os

#set path where the shapefiles are located
arcpy.env.workspace = "Z:/temp"


#returns @string list of GDB folders
workspaces = arcpy.ListWorkspaces('*', "FileGDB")
for item in workspaces:
    print item
    env.workspace = item


#returns @string list of feature classes
    fcs = arcpy.ListFeatureClasses()
    for file in fcs:
        print '\t', file

 # set local variables
        for file in fcs:
          inData = file
          coordinateSystem = arcpy.SpatialReference(4283)
          arcpy.DefineProjection_management(inData, coordinateSystem)
9

You appear to be confusing two tools:

  • Define Projection which simply assigns a coordinate system to a dataset without changing that data i.e. the X,Y values all stay the same
  • Project which projects data in one coordinate system into another i.e. the X,Y values undergo complex calculations (projection) to change them into values that match the new desired coordinate system

I suspect that it is the Project tool which you should be using here.

  • That's a very common misconception, I've seen it so many times.. in Esri and QGIS. Nice code though, I reckon it's worth a +1 just for the clearly readable and commented code. Tony, have a look at arcpy.da.walk() resources.arcgis.com/en/help/main/10.2/index.html#//… especially the two examples given.. I found it a better way to iterate feature classes in a database than the old method of listing the standalones then iterating each dataset... just saying. – Michael Stimson Aug 19 '16 at 1:52
  • Tony you can see how to use the arcpy.da.walk that @Michael mentions in the answer I gave on your other question yesterday. You probably just need to change the define protection to project as PolyGeo says – Midavalo Aug 19 '16 at 3:57

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.