Select to view content in your preferred language

ArcScene - sort group layer

2338
3
08-02-2011 02:27 AM
deleted-user-VeZur_n9o0OZ
Deactivated User
Hi all,

I'm using ArcScene 10 for the first time and have a group layer containing a ton of rasters (raster catalog cannot render at good enough quality). I need to sort this group alphabetically but can't figure out how to even get a handle on my sxd document. Any tips? The forum is empty of ArcScene/python threads

Cheers,
James
Tags (2)
0 Kudos
3 Replies
JakeSkinner
Esri Esteemed Contributor
Have you considered using a mosaic dataset?  This is essentially a raster dataset and raster catalog hybrid.  It renders much faster due to the mosaic datasets overviews.  This is the recommended approach when dealing with a large collection of rasters.

Here is another helpful link and a video on mosaic datasets.
0 Kudos
deleted-user-VeZur_n9o0OZ
Deactivated User
Yes the mosaic was my first port of call. Unfortunately ArcScene doesn't support mosaics so i had to build the catalog. I then found out the catalog cannot render at the high enough quality as Scene is memory based (even with a definition query turned on). So I then created all my tiles separately and only turn on a handful at a time.

I know want to write a python script to sort these alphabetically rather than drag and drop.

Cheers,
James
0 Kudos
JakeSkinner
Esri Esteemed Contributor
I could not find a way to access an ArcScene document (.sxd) using python either.  The best approach I found was to copy your group layer to ArcMap by right-clicking on the group layer in ArcScene > Copy > right-click on ArcMap's data frame > Paste Layer(s).  Next save the map document.  Once you have the saved MXD you can run python on the group layer to sort the layer alphabetically.  After the group layer is sorted in ArcMap, you can copy/paste the group layer back into the SXD. 

Here is an example how to sort the Group Layer:

import arcpy
from arcpy import env
from arcpy import mapping
env.overwriteOutput = True

env.workspace = r"C:\temp\python"

folder = env.workspace

mxd = mapping.MapDocument(r"C:\temp\python\Scene.mxd")

list = []


for df in mapping.ListDataFrames(mxd, "*"):
    for lyr in mapping.ListLayers(mxd, "*", df):
        # Find layers within Group Layer
        if "\\" in lyr.longName:
            lyrName = str(lyr.name) + ".lyr"
            list.append(lyrName)
        # Save layers to .lyr files
            arcpy.SaveToLayerFile_management(lyr, lyrName)
        # Remove layers from Group Layer
            mapping.RemoveLayer(df, lyr)

print "Successfully created layer files and removed layers"      

# Order layer files in alphabetical order
list.sort(key=lambda x: x.lower())

# Add layer files to Group Layer in alphabetical order
for df in mapping.ListDataFrames(mxd, "*"):
    for n in list:
        for lyr in mapping.ListLayers(mxd, "3D", df):
            targetGroupLayer = lyr
            addLayer = mapping.Layer(folder + "\\" + n)
            mapping.AddLayerToGroup(df, targetGroupLayer, addLayer, "BOTTOM")

print "Successfully reorderd Group Layer"

# Delete lyr files
lstFiles = arcpy.ListFiles("*.lyr")
for file in lstFiles:
    arcpy.Delete_management(file)

print "Sucessfully deleted layer files"    

mxd.save()
del mxd
0 Kudos