I am trying to create file geodatabase and create a mosaic dataset; however I do know that creating a file geodatabase works but the mosaic dataset is not...
I think there must be a way to force the dataset within the file geodatabase but it is blocking me ?
Take a look at my codes
Thanks.
################################################################################ # CREATE FILE GEODATABASE AND THEN CREATE MOSAIC DATASET # ################################################################################ # Name: CreateFileGDB_Example2.py # Description: Create a file GDB # Import system modules import arcpy # Set local variables out_folder_path = "C:/workspace" out_name = "test.gdb" # Execute CreateFileGDB Test = arcpy.CreateFileGDB_management(out_folder_path, out_name) # Creating new Mosaic Dataset within Existing File Geodatbase # Set NAD 1983 UTM Zone 13N sr = arcpy.SpatialReference(26913) mdname = "/SeeIfThisWorks" try: # To see if the file exists or not Test = arcpy.CreateFileGDB_management(out_folder_path, out_name) #Then create the file mdname= arcpy.CreateMosaicDataset_management(out_folder_path,Test,mdname) except: str = "Your Mosaic Dataset" +str2+"" "is done created" str2 = "Test" print str + str2
You can resolve your problem with this code by reading the help for this tool. Look at the syntax section in the help file, the parameters in your code are incorrect for the CreateMosaicDataset tool. If you actually scroll to the bottom of the help file you'll see a sample of code using the tool.
It's all the help file...
error messages are also required, just copy and paste them
Try following changes:
1. Import arcpy, os
2. mdname = "SeeIfThisWorks"
3. mdname= arcpy.CreateMosaicDataset_management(os.path.join(out_folder_path,Test),mdname)
Hope this is helpful
Kishor
As Duncan already pointed out, the help page lists the required parameters (there are THREE of them).
Why do you create the geodatabase twice? (in line 20 and line 33) You should create it once. It could be the source of your error
Also your try/except block is wrong. Within the try section, you attempt to do the work...that is fine... Your except block is supposed to provide you with what to do when the try block DOES NOT WORK, you have it reporting that the try block was successful, and not a dismal failure.
So try this
import arcpy arcpy.env.overwriteOutput = True .... code stuff in preparation for try/except block try: 'do magic' except: 'when magic fails ... do this ' print " failed again....sigh...."
replacing 'do magic' and 'when magic fails ... do this ' with appropriate code.
Good news !
While I have been figuring it out and looking at the help on this problem..Sigh It is been battle back and forth for me . The problem is in the Creating Mosaic Dataset..
This works ! I have made a lot of change from the original code I post yesterday...
I had to copy the code from this reateMosaicDataset example 2 (stand-alone script) ArcGIS Help 10.1
it was giving several problems.... the prjfile does not work...
so I add the the SpatialReference with WKID in it
and make sure the code in one line..example see 26
################################################################################ # CREATE FILE GEODATABASE AND THEN CREATE MOSAIC DATASET # ################################################################################ # Name: CreateFileGDB_Example2.py # Description: Create a file GDB # Import system modules import arcpy,os,sys arcpy.env.workspace = "C:/workspace" # Set local variables out_folder_path = "C:/workspace" out_name = "Think.gdb" # Execute CreateFileGDB arcpy.CreateFileGDB_management(out_folder_path, out_name) # Creating new Mosaic Dataset within Existing File Geodatbase try: gdbname = "Think.gdb" mdname = "SeeIfThisWorks" prjfile = arcpy.SpatialReference(26913) noband = "3" pixtype = "8_BIT_UNSIGNED" pdef = "NONE" wavelength = "" arcpy.CreateMosaicDataset_management(gdbname, mdname, prjfile, noband,pixtype, pdef, wavelength) except: print "Create Mosaic Dataset failed"