Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

ApplySymbologyFromLayer Not Working for Raster Mosaic Dataset

$
0
0
I am thoroughly flummoxed with this issue!

I've created a set of daily surfaces representing groundwater levels. I want to step through them in time (i.e., make them time-enabled). I found a good site ( http://esriaustraliatechblog.wordpre...abled-rasters/ ) that essentially said to create a raster mosaic dataset, add all my daily surfaces, and create a field that represents the date. That works great!

Now, I want to color-ramp the mosaic dataset. I'm able to do that and have saved it as a layer file.

The code below crashes when I try to apply the saved layer file to my surface raster mosaic dataset, saying

"ERROR 000968: The symbol layer does not match the input layer

Ultimately, I'll want to re-classify the raster because different datasets will have different min/max values.

Any ideas?

Jon Mulder

Code:

import arcpy
import arcpy.mapping
import datetime
import os

##Reference the Current map document.
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
GeoDatabaseNameAndLocation = "G:\Documents\GIS\HydstraData\HydstraMeasurementsDeep\Contours_Daily_20130601_20130605.gdb"
LayerFileNameAndLocation_WSE_Surface = "G:\Documents\GIS\HydstraData\Template_WSE_Surface.lyr"
arcpy.AddMessage(LayerFileNameAndLocation_WSE_Surface)
CurrentSurface = os.path.join(GeoDatabaseNameAndLocation,"WSE_RasterMosaicDataset")
arcpy.AddMessage(CurrentSurface)
Surface_lyr = arcpy.mapping.Layer(CurrentSurface)
arcpy.mapping.AddLayer(df, Surface_lyr, "BOTTOM")
arcpy.ApplySymbologyFromLayer_management(Surface_lyr,LayerFileNameAndLocation_WSE_Surface)


=====Error Message======================================
Executing: AddRaster
Start Time: Tue Jan 07 10:22:53 2014
Running script AddRaster...
G:\Documents\GIS\HydstraData\Template_WSE_Surface.lyr
G:\Documents\GIS\HydstraData\HydstraMeasurementsDeep\Contours_Daily_20130601_20130605.gdb\WSE_RasterMosaicDataset

Traceback (most recent call last):
File "G:\Documents\GIS\HydstraData\AddRasterMosaicToCurrentMap_20140107.py", line 16, in <module>
arcpy.ApplySymbologyFromLayer_management(Surface_lyr,LayerFileNameAndLocation_WSE_Surface)
File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 5754, in ApplySymbologyFromLayer
raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000968: The symbol layer does not match the input layer
Failed to execute (ApplySymbologyFromLayer).


Failed to execute (AddRaster).
Failed at Tue Jan 07 10:22:58 2014 (Elapsed Time: 4.64 seconds)

Viewing all articles
Browse latest Browse all 2485

Trending Articles