Enable Z values on an existing Featureclass

7091
3
06-26-2012 09:50 AM
MatthewWalker1
New Contributor III
I am trying to write a python script to take an existing featureclass that does not support Z or M values and enable enable them.  I know that this cannot be done on an existing featureclass (why, I'm not sure!) so I wrote my script to create a new featureclass using the original as a template, then copy over all existing data, delete the original featureclass, then rename the new one to the original name.  Sounds great, but the issue now is that if you create a featureclass using a featureclass that does not support Z values, the newly created one will also not support Z values, even is explicitly set to 'ENABLED' in the code.  Does anyone know how this can be done, or if there is any errors in my code:

import arcpy
from arcpy import env
import os
import datetime
env.workspace = "database connections\BASE.sde\BASE.BASE.Test"
Path = r"database connections\BASE.sde\BASE.BASE.Test\BASE.BASE."
arcpy.env.overwriteOutput = True

#Prompt user for FC to copy
FC_Copy = raw_input("Enter Featureclass name to copy: ")
#Copy original FC to a new '_Temp' FC
arcpy.CreateFeatureclass_management(env.workspace, FC_Copy+"_Temp", "POLYLINE", Path + FC_Copy, "ENABLED", "ENABLED")
print "Table " + FC_Copy + "_Temp added..."
#Copy over existing data-how to ensure ObjectID's don't change?
arcpy.Copy_management(Path + FC_Copy, Path + FC_Copy + "_Temp")
print "Copied original records to " + FC_Copy + "_Temp..."
#Delete original FC
FC = Path + FC_Copy
arcpy.Delete_management(FC)
print "Original Table, " + FC + ", has been deleted..."
#Rename copied FC to original name
arcpy.Rename_management(Path + FC_Copy + "_Temp", FC_Copy)
print "New Featureclass, " + FC_Copy + "_Temp, renamed to " + FC_Copy + ". Z-enabling script is completed successfully"

Tags (2)
0 Kudos
3 Replies
MathewCoyle
Frequent Contributor
Have you tried inserting Z values to each X,Y vertex in the new Z enabled feature class? Where are your Z values coming from? I've added elevation to a feature class by pulling the average from a DEM to a defined polygon mask, but never actually added Z values to a feature class.

There is this in the help that may give you some more information on how to go about solving your problem.
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00q80000009s000000.htm

Edit: Also, try setting the Z-values in the environment settings as per this thread.
http://forums.arcgis.com/threads/22826-Converting-2D-Features-to-3D
0 Kudos
MatthewWalker1
New Contributor III
Have you tried inserting Z values to each X,Y vertex in the new Z enabled feature class? Where are your Z values coming from? I've added elevation to a feature class by pulling the average from a DEM to a defined polygon mask, but never actually added Z values to a feature class.

There is this in the help that may give you some more information on how to go about solving your problem.
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00q80000009s000000.htm

Edit: Also, try setting the Z-values in the environment settings as per this thread.
http://forums.arcgis.com/threads/22826-Converting-2D-Features-to-3D


My issue concerns going forward and having the new feature support Z values, so that new data collection would contain Z and/or M values, not so much pushing legacy data into a newly built Z enabled feature.  I am ultimately looking for a script or tool to take a customer's non Z supported database and convert it easily to a Z enabled database, which could contain 10, 20, 50 or more features, and building out all new features manually would be a huge hassle.  I feel that my code above is close, but there seems to be an issue or a software defect that will not allow me to use a (non Z supported) template when creating new Featureclasses, and if that were resolved, I could automate the 'updating' of current features to support Z or M values.  Is there a known or suspected defect concerning this, or is there something in my code that is wrong or missing?
0 Kudos
MathewCoyle
Frequent Contributor
Like I said, I have never tried this process before, but you might want to try an insert cursor to get the feature by feature data without taking all the data associated with the entire feature class that comes through in a copy. You can also try creating a dummy feature as the first feature in the empty feature class and assign it x,y,z values to force it to be Z enabled. These are just shots in the dark really, hopefully someone else can shed some more insight into the situation than I can.
0 Kudos