1

I have a mosaic layer that I want to add to my map in ArcMap. When I add this layer manually (i.e the "Add Data" button), a raster image, a boundary, and a footprint are added to my table of contents. However, when I run the following code, only the raster image is added to my TOC. I have no idea why this happens. How do I get my code to also add the footprint and boundary to the map?

    import arcpy
    in_workspace = r"C:\Users\Christian\Documents\ArcGIS\Default.gdb"
    in_mosaicdataset_name = "mosaic_file"
    mxd = arcpy.mapping.MapDocument("CURRENT")
    df = arcpy.mapping.ListDataFrames(mxd)[0]
    path_to_layer = in_workspace+"\\"+in_mosaicdataset_name
    layer = arcpy.mapping.Layer(path_to_layer)
    arcpy.mapping.AddLayer(df,layer,"BOTTOM")
  • 1
    That would be 3 separate layers, the raster and two vectors. I'm not sure you can access those from arcpy. You could try making a mosaic layer and adding that help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//… – Michael Stimson Jul 30 '14 at 1:25
  • Are you trying to add the grid footprint associated to a raster catalog? – artwork21 Jul 30 '14 at 1:46
  • @artwork21 I would like to see the boundary and the footprint of the raster file. I created a mosaic and then added a raster file to it. When I add that mosaic with "add data", I see the image, footprint, and boundary in my Table of Contents. When I add that same mosaic with the above script, I only see the image. – Christian Carrick Jul 30 '14 at 1:53
  • It may be a property setting, see this Q/A, gis.stackexchange.com/questions/49801/… – artwork21 Jul 30 '14 at 1:55
1

As originally edited into the question by its asker (who has not been on the site for two years):

Michael Miles-Stimson's idea worked. The following code produced the desired result:

    import arcpy
    arcpy.env.workspace = r"C:\Users\Christian\Documents\ArcGIS\Default.gdb"
    in_mosaicdataset_name = "mosaic_file"
    mxd = arcpy.mapping.MapDocument("CURRENT")
    arcpy.MakeMosaicLayer_management(in_mosaicdataset_name,in_mosaicdataset_name+"_layer")
    arcpy.SaveToLayerFile_management(in_mosaicdataset_name+"_layer",in_mosaicdataset_name+"_layer.lyr")
    layer = arcpy.mapping.Layer(in_mosaicdataset_name+"_layer")
    df = arcpy.mapping.ListDataFrames(mxd)[0]
    arcpy.mapping.AddLayer(df,layer,"BOTTOM")

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.