I am trying to create multiple Referenced Mosaic Datasets with different names and coordinate systems based on 1 source mosaic dataset.

My code is as follows:

# test referenced mosaic dataset creation
import arcpy, os, time, sys
import arceditor #this is required to create a mosaic dataset from images

# Define local variables:
# the folder of input images
ImageSource = r"\\fileshare\data\source\Raw_Imagery"
# the folder for mosaic dataset and the service defintion draft file
MyWorkspace = r"\\fileshare\data\publishing"

GDBpath = os.path.join(MyWorkspace,GdbName) #File geodatabase used to store a mosaic dataset
Name = "World_Imagery"
refNames = ["World_Imagery_Mercator", "World_Imagery_WGS84", "World_Imagery_WorldMercator"]
Md = os.path.join(GDBpath, Name)
Sddraft = os.path.join(MyWorkspace,Name+".sddraft")
Sd = os.path.join(MyWorkspace,Name+".sd")
con = os.path.join(MyWorkspace, "svrconnection.ags")
SrsLookup = {
  'Mercator': "PROJCS['World_Mercator',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137,298.257223563]],PRIMEM['Greenwich',0],UNIT['Degree',0.017453292519943295]],PROJECTION['Mercator'],PARAMETER['False_Easting',0],PARAMETER['False_Northing',0],PARAMETER['Central_Meridian',0],PARAMETER['Standard_Parallel_1',0],UNIT['Meter',1]]",
  'WGS84': "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137,298.257223563]],PRIMEM['Greenwich',0],UNIT['Degree',0.017453292519943295]]",
  'World Mercator': "PROJCS['WGS_1984_World_Mercator',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Mercator'],PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',0.0],PARAMETER['Standard_Parallel_1',0.0],UNIT['Meter',1.0],AUTHORITY['EPSG',3395]]"

# First author a mosaic dataset from a folder of images
    print "Creating fgdb"
    arcpy.CreateFileGDB_management(MyWorkspace, GdbName)

    print "Creating Source mosaic dataset"
    arcpy.CreateMosaicDataset_management(GDBpath, Name, SrsLookup['WGS84'], "", "", "NONE", "")

    print "Adding images to mosaic dataset" # also caculate cell size range, build boundary, and build overviews
    arcpy.AddRastersToMosaicDataset_management(Md, "Raster Dataset", ImageSource, "UPDATE_CELL_SIZES", "UPDATE_BOUNDARY", "UPDATE_OVERVIEWS", "#", "0", "1500", "#", "#", "SUBFOLDERS", "ALLOW_DUPLICATES", "NO_PYRAMIDS", "NO_STATISTICS", "NO_THUMBNAILS", "", "NO_FORCE_SPATIAL_REFERENCE")
    print arcpy.GetMessages()+ "\n\n"
    sys.exit("Failed in authoring a mosaic dataset")

    for ref in refNames:
        print "Creating Referenced mosaic dataset"
        arcpy.CreateReferencedMosaicDataset_management(os.path.join(GDBpath, Name), os.path.join(GDBpath, ref), SrsLookup['Mercator'], "#", "#",
                                                       "#", "#", "#", "#", "#", "#", "#", "#", "BUILD_BOUNDARY")

    print arcpy.GetMessages() + "\n\n"
    sys.exit("Failed in authoring a referenced mosaic dataset")

So, as you can see in the code, I used the refNames list to iterate through the 3 names which creates 3 referenced mosaic datasets, but I am unsure as to how to do the same thing for the coordinate systems which I currently have within a dictionary lookup.

I have also considered maybe putting an IF statement before the reference mosaic creation, or potentially making the refNames list into a dictionary also.

Any ideas how to get the coordinate systems to loop through at the same time?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.