CalculateStatistics on Mosaic Dataset

568
4
12-16-2013 04:28 AM
JamesCrandall
MVP Frequent Contributor
I am attempting to calculate statistics on mosaic datasets in a FGDB.  It appears to work correctly however it runs and I add the mosaic to the TOC and access the symbology properties of the Mosaic dataset, it does not allow for Classified type (only Stretched and Discrete color are available). 

I am expecting to be able to apply a classified renderer on the mosaic, which it works as expected if I manually run the Calculate Statistics from the "Enhance" menu (by right clicking on the mosaic in the catalog tree and accessing this menu option there).

Is there any reason why I can access the classified symbol property after running calculate stat from the Enhance menu, but not from the code below?

Thanks,
j



def calcStatsMOSAIC(t):

  try:
      
    arcpy.env.workspace = ws_output

    bndy_mosaic = str(ws_output) + "\\rasext" + str(t)
    mosaic_name = "ConcMosaic" + str(t)
    ws_mosaic = str(ws_output) + "\\" + str(mosaic_name)
    tr = "*Mosaic*"
    rasters = arcpy.ListDatasets(tr) 
    for r in rasters:
        
       ##CALC STATISTICS
       arcpy.CalculateStatistics_management(ws_mosaic, 1, 1, "#", "OVERWRITE", bndy_mosaic)

Tags (2)
0 Kudos
4 Replies
JamesCrandall
MVP Frequent Contributor
bump to the top
0 Kudos
JakeSkinner
Esri Esteemed Contributor
Hi James,

I've noticed after a mosaic dataset is created and statistics are calculated using a script, they will not show until you restart ArcMap.  You may want to follow up with Tech Support on this.  Also, you can simplify your script:

def calcStatsMOSAIC(t):
    arcpy.env.workspace = ws_output
    mosaic_name = "ConcMosaic" + str(t)
    arcpy.CalculateStatistics_management(mosaic_name, 1, 1)


Try the following:

1.  Create your mosaic dataset
2.  Run the script
3.  Restart ArcMap
4.  Add the mosaic dataset to ArcMap and see if you 'Classified' for a symbology type
0 Kudos
JamesCrandall
MVP Frequent Contributor
Hi James,

I've noticed after a mosaic dataset is created and statistics are calculated using a script, they will not show until you restart ArcMap.  You may want to follow up with Tech Support on this.  Also, you can simplify your script:

def calcStatsMOSAIC(t):
    arcpy.env.workspace = ws_output
    mosaic_name = "ConcMosaic" + str(t)
    arcpy.CalculateStatistics_management(mosaic_name, 1, 1)


Try the following:

1.  Create your mosaic dataset
2.  Run the script
3.  Restart ArcMap
4.  Add the mosaic dataset to ArcMap and see if you 'Classified' for a symbology type



Thanks for your input, Jake,

I ran the script/.py from PythonWin and from a Toolbox Script, both have the same result even after restarting ArcMap.

Also, I appreciate the simplification suggestion.  I need to iterate over raster datasets as shown because there are both mosaic's and individual rasters, which I just need to acquire the mosaic to calc the statistics.
0 Kudos
JamesCrandall
MVP Frequent Contributor
I think I have narrowed down the problem to the Area of Interest parameter.

1.  In my script, I dynamically create a polygon feature class that is the same extent of the footprint/boundary of the mosaic.  This FC does reside in the same FGDB as the mosaic, but is its own feature class.

2.  Running Calculate Statistics toolbox script (which successfully adds classified symbology property) auto-populates the Area of Interest parameter with: CalculateStatistics::area_of_interest and adds an empty polygon fc to the Table of Contents. 

So, there is something going on there with the tool adding CalculateStatistics::area_of_interest that I am not understanding.  Any additional input is appreciated.

j
0 Kudos