Projecting features to dataset

392
2
05-25-2011 09:40 AM
MathewCoyle
Frequent Contributor
Hi all, I am having some problems projecting data from a dataset into another dataset. The output always seems to go to the root output geodatabase location, instead of the defined dataset. I've tried making the output dataset the workspace and still it does not go there. Is this working as intended and I am just missing something? Here is the code below. I eventually hope to be able to loop through multiple datasets, but I have it hardcoded to just get it to do one for now.

I am able to do other exports and I checked to make sure they have the same spatial reference. Any ideas?

sde = r"D:\sde_transit\sde1.gdb\\"
output = r"D:\sde_transit\sdeNAD83.gdb\\"
arcpy.env.workspace = sde
outCS = r"C:\Program Files (x86)\ArcGIS\Desktop10.0\Coordinate Systems\Projected Coordinate Systems\UTM\NAD 1983\NAD 1983 UTM Zone 12N.prj"
transformation = r"NAD_1927_To_NAD_1983_NTv2_Canada"
inCS = r"C:\Program Files (x86)\ArcGIS\Desktop10.0\Coordinate Systems\Projected Coordinate Systems\UTM\NAD 1927\NAD 1927 UTM Zone 12N.prj"

dsList = arcpy.ListDatasets("", "Feature")
fcList = arcpy.ListFeatureClasses("","",dsList[3])
for feature in fcList:
 desc = arcpy.Describe(feature)
 print desc.name
 featout = output+dsList[3]+"\\"+desc.name
 print featout
 arcpy.Project_management(feature, featout, outCS, transformation, inCS)
Tags (2)
0 Kudos
2 Replies
danbecker
Occasional Contributor III
this should get ya going. I didn't see the need for the .describe since your end goal is to loop through datasets/features anyway. Take note of the "*" wildcards in the listdatasets and listfeatureclasses methods. You could enter "utilities*" to only loop through all feat. datasets that begin with "utilities".


dsList = arcpy.ListDatasets("*", "Feature")
for dataset in dsList:
    arcpy.env.workspace = sde + "\\" + dataset
    fcList = arcpy.ListFeatureClasses("*")
    for feature in fcList:
        arcpy.env.workspace = dataset + "\\" + feature
 featout = output + dataset + "\\" feature
 print featout
 arcpy.Project_management(feature, featout, outCS, transformation, inCS)
0 Kudos
MathewCoyle
Frequent Contributor
Thanks for the help Dan. I ended up just projecting the dataset as a whole. I hadn't realized the project tool supported that.
0 Kudos