Thursday 30 July 2015

arcpy - Using Python, Batch Project output won't drop into feature dataset?


When attempting to batch project in ArcGIS 9.3 or 10 (using either arcpy or arcgisscripting), I cannot get my geoprocessing results to drop into the feature dataset that I specify. The results instead are dropped in the root of the Geodatabase (*.mdb).


Here's an abbreviated version of what I have so far:


import arcgisscripting, os
gp = arcgisscripting.create(9.3)

#set date
dmy = datetime.now()

currentDate = str(dmy.month) + "-" + str(dmy.day) + "-" + str(dmy.year)

outputfolder = gp.getparameterastext(0) #where we're going to drop the gdb
citydata = gp.getparameterastext(1)

gp.workspace = outputfolder
projectedfolder = os.path.join(outputfolder, "projected")
gp.CreateFolder_management(*os.path.split(projectedfolder))
gdb = "Projected_Data_" + currentDate + ".mdb"


#set coordinate system
outputCS = gp.CreateObject("SpatialReference")
outputCS.createFromFile(os.path.join(gp.getinstallinfo()['InstallDir'], "Coordinate Systems\\Geographic Coordinate Systems\\North America\\NAD 1983.prj"))
transformation = ""

gp.AddMessage("Creating City feature dataset")
gp.CreateFeatureDataset(os.path.join(projectedfolder, gdb), "City", outputCS)

gp.AddMessage("Loading in City feature classes")
arcpy.BatchProject_management(citydata, os.path.join(projectedfolder, gdb, "City"), outputCS, "", transformation)


Obviously, the part I'm having trouble with is the Output Path in the last line. I've also hard-coded the path to the "City" feature dataset, but still drops it in the root. Any ideas?


(Cross-posted at ESRI Forums here)



Answer



Many people have asked about this. At least one request (NIM013677) has been rejected with the status "as designed." The reason given is:



Because when using the script version, the tool cannot know whether the target is a dataset or a feature class. It is designed to not support a feature dataset.



Std Disclaimer: I work at Esri, but not on the geoprocessing team (who made this decision).


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...