Get mosaics, with color ramp "Full Spectrum-Bright"

1366
9
06-30-2013 07:24 PM
GualbertoHernandez
New Contributor
Hi all,

I'm writing a script to generate mosaics, the problem is that I get are by default grayscale, ie the color ramp "Black to White", and I need to get them in the color ramp "Full Spectrum-Bright" as I can do this with Python?

Thanks for your help.

Gualberto
Tags (2)
0 Kudos
9 Replies
RhettZufelt
MVP Frequent Contributor
Are you talking about the color ramp when you load into ArcMap?

If so, can you change it to what you want in the symbology properties?  Also, if so, not sure you can assign this to the mosaic itself.

When my ArcMap started loading .tiff files as greyscale by default (I had to go into symbology and change color ramp) it was an ArcMap setting that had gotten corrupted.  Had to wipe my ESRI registry folder and re-buid it.

R_
0 Kudos
GualbertoHernandez
New Contributor
rhett,

That's exactly what I need, know if you can do with Python. The mosaic that I'm getting is with a script from a netcdf file.

regards
GHJ
0 Kudos
markdenil
Occasional Contributor III
You can assign a colormap, but that only applies to certain types of rasters,
and it only assigns colors to specified unique values.

If you save a rendered raster (one with your desired symbol schema applied) as a layer file,
you can use Apply Symbology From Layer (Data Management).
0 Kudos
RhettZufelt
MVP Frequent Contributor
Well, not sure what you are trying to do.  A raster is a raster, it is the software that your are viewing it with that determines what colors or greyscales are used for display.

As pointed out, if your data supports a colormap (single band non float raster), you can add a colormap to it.  However, this will only be honored in applications that support it.

Also, if you change the default settings of how your particular install of ArcMap loads rasters by default (as posted in your other thread on this), will have the same affect when loading into ArcMap.

Can also symbolize as you want, and create a layer file.  Then, when you load this layer file into ArcMap, it will load the raster with the symbology you want.

If you are using arcpy.mapping function to generate an output from an mxd, then you could either have a colormap (if supported), load into the mxd using your pre-sybolized layer file, or load into mxd and use arcpy.mapping.updatelayer to update the symbology to a pre-defined .lyr file.

If you want a colormap, and are in fact actually using a "mosaic", and not just raster data, it looks like you apply the colormap (arcpy.AddColormap_management) to the raster before you incorporate into the mosaic.

So, I guess it depends on what the purpose of this data set is, where are you viewing/using it, what software, etc. to determine best course of action.

R_
0 Kudos
markdenil
Occasional Contributor III
Well, I don't know about this "A raster is a raster" thing...
...because there are rasters and then there are rasters.

For example, attaching a colormap to a raster that supports colormaps allows one
to save that single band raster as a three band (color) tiff.
The tiff would have the color information internally, and available in situations
where other coloring (through colormaps or ArcMap rendering (through the interface or saved as a layer)
would not work.

That sounds vaugly like what Gualberto might want to do...

It is true that we don't know the full details of what end result Gualberto wants or expects
and sometimes it is hard to guess the best approach on such limited knowledge.
So.. I give some general advise. It is worth every penny paid for it.
0 Kudos
RhettZufelt
MVP Frequent Contributor
Ok, I agree, there are different "forms" of rasters, though they are all pretty much a series of "cells" with a value attached.

The point I was trying to make, is that the "color", "symbology", "rendering", or whatever you want to call it is determined by the software package itself based on the value of the cell.

Sure, if there is a color map (a separate lookup table of value:color that is NOT actually part of the raster) (of course, tiff's have the 'color map" as part of the attribute table), some software can utilize that to symolize the data, but can easily be circumvented in the displaying software package.

I have three band full color tiffs, but if I load them into my 9.3.1 ArcMap, they display as greyscale/stretched (due to the ArcMap settings and nothing to do with the raster itself).

If I load the same tiff in my 10.1 app, they load as RGB color images.  however, I can go in and change the symbology in arcmap and turn it into streched, greyscale, base each band on a different color ramp, etc, and reder it however I choose. Can also save the "new" colors to a layer file

With such limited information in the original post, It sounded like the original poster is under the impression that the color ramp used to display in ArcMap was actually a "setting" in the raster itself.

I was trying to make it clear that this is controlled in ArcMap (or whatever app you are "rendering" it with).

R_
0 Kudos
GualbertoHernandez
New Contributor
Hi all,

I commented that 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 aparace 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 aparace 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 



          
            
          
                 







0 Kudos
GualbertoHernandez
New Contributor
Sending an image of the mosaic obtained

regards
Gualberto
0 Kudos
RhettZufelt
MVP Frequent Contributor
Once you load the mosaic into ArcMap, can you manually change the symbology to the color ramp that you want or will it not let you?

R_
0 Kudos