Problems with color ramp in MOSAIC DATASET

707
0
07-05-2013 01:28 AM
GualbertoHernandez
New Contributor
Hi all,

I have tried the following to get the mosaic with the color ramp "Full Spectrum-Bright" and unfortunately none I have found.

1. Modifying "AdvancedArcMapSettings" the default options for rasters.

2. using "arcpy.AddColormap_management" for each raster before they are added to the mosaic, (this option does not help because the content of the raster (pressure reduced to sea level) varies with respect to the ctl, so get in several of them "NODATA"

3. For each raster just before being added to the mosaic, apply "arcpy.MakeRasterLayer_management" and "arcpy.ApplySymbologyFromLayer_management" and implemented correctly, but at the time of being added to the mosaic and open this, I incredibly appears the color ramp in Grayscale "

The conclusion is that I have managed to assign the color ramp "Full Spectrum-Bright" to each raster, but you see that are added to the mosaic and display it in ArcMap I appears in grayscale.

I hope you can help me, I think now I'm desperate, this is my code.
import arcpy
import glob, os
import time
from time import localtime
from time import strftime
import datetime


tic = time.clock()


#*********** PRINCIPALES VARIABLES *************

arcpy.env.overwriteOutput = True

prefijo = "PruebaPronostico.SDE."
variable = "pslv"
inNetCDF = "C:\Datos_IIE\pruebasmosaico\SalidasNETCDF/DOMAIN1_2013070318.nc"
outLoc = "Database Connections/Con_PruebaPronostico.sde/"
outLoc2 = "C:\Datos_IIE\pruebasmosaico/raster/"

# Process: Create Mosaic Dataset
arcpy.CreateMosaicDataset_management(outLoc, variable, "PROJCS['Lambert_Conformal_Conic',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Lambert_Conformal_Conic'],PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',-27.0],PARAMETER['Central_Meridian',-124.17],PARAMETER['Standard_Parallel_1',0.0],PARAMETER['Standard_Parallel_2',0.0],PARAMETER['Scale_Factor',1.0],PARAMETER['Latitude_Of_Origin',0.0],UNIT['Kilometer',1000.0]];-20037.7 -30225.3 149134210447.956;1 1;1 1;0.000001;2;2;IsHighPrecision", "", "")


nc_FP = arcpy.NetCDFFileProperties(inNetCDF)
nc_Dim = nc_FP.getDimensions()

#rr = outLoc2 + '*'
#r = glob.glob(rr)
#for e in r:
#   os.remove(e)

test = outLoc + '*'
r = glob.glob(test)
list = []

for i in r:
   os.remove(i)

for dimension in nc_Dim:

    top = nc_FP.getDimensionSize(dimension)

    for i in [0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 102, 108, 114, 120]:

        if dimension == "time":

            dimension_values = nc_FP.getDimensionValue(dimension, i)
            daat = "time '"+str(dimension_values)+ "'"
            print dimension_values

            nowFile = str(i)
            testt = dimension_values.replace("/","").replace(":","").replace(".","").replace("'","").replace(' ','')
            rast = name6 + name5 + name4 + "_" + name7
            list.append(dimension_values)

            rastt = "time" + nowFile

            print rast
          
            # Convierte todos los tiempos del NETCDF A LAYER
            
            arcpy.MakeNetCDFRasterLayer_md(inNetCDF, variable, "lon", "lat", testt, "", daat, "BY_VALUE")

             # CONVIERTE LAS LAYER A RASTER Y LOS GUARDA EN EL DIRECTORIO INDICADO
            arcpy.CopyRaster_management(testt, outLoc2 + rastt, "", "", "-3,402823e+038", "NONE", "NONE", "", "NONE", "NONE")

            #arcpy.MakeRasterLayer_management(outLoc2 + rastt, "rastt", "#", "feature.shp", "1")
            arcpy.MakeRasterLayer_management(outLoc2 + rastt, rastt, "", "0 706.764 5373 4729.764", "")

            # APLICAR SIMBOLOGÍA

            arcpy.ApplySymbologyFromLayer_management (rastt, "C:\Datos_IIE\pruebasmosaico\sombologia.lyr")
            
             # Process: Add Rasters To Mosaic Dataset
            arcpy.AddRastersToMosaicDataset_management(outLoc +  variable, "Raster Dataset", rastt, "UPDATE_CELL_SIZES", "NO_BOUNDARY", "NO_OVERVIEWS", "", "0", "1500", "", "", "SUBFOLDERS", "ALLOW_DUPLICATES", "true", "true", "NO_THUMBNAILS", "")

           #Assign colormap using clr file
            ###arcpy.AddColormap_management(outLoc2 + rast, "#", "C:/Datos_IIE/pruebasmosaico/test3.clr")

# Process: Add Field
arcpy.AddField_management(outLoc +  variable, "tiempo", "DATE", "", "", "", "T", "NULLABLE", "NON_REQUIRED", "")

# Process: Calcular stadisticas
arcpy.BatchCalculateStatistics_management(outLoc +  variable)


# Agregamos el tiempo a los raster dentro del mosaico

mm = len(list)
for j in range(1, mm):

#******************************Funciona para una celda **********
     with arcpy.da.UpdateCursor(outLoc +  variable,
                          ["tiempo", "OBJECTID"]) as cursor:
      for row in cursor:
           index = int(row[1])
           print index
           row[0] = time.strftime(str(list[index-1]))
           cursor.updateRow(row)
#*******************************************************************       


toc = time.clock()
print toc - tic


Attached python script, and a picture of my mosaic

Thamks,
Gualberto
Tags (2)
0 Kudos
0 Replies