Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

This question is relative to a past question of mine at Rendering raster layer from DTED based on height color map (that remained unanswered), so if you believe that I should merge those two, let me know.

I have a MADtedLayer created from a dted catalog using military analyst. The only way I managed to display the data, was using the UseUniformRenderer property of the layer. I want to be able to change the renderer. To be more precise, I want to display each elevation with a specific color, that is already available from a file.

My guess is that I need a RasterDiscreteColorRenderer with a corresponding RasterColormap (although I'been unsuccesful with a StretchRenderer also)

Here I provide my un-succesful so far code:

public IRasterRenderer CreateDtedRenderer()
{
    IRasterColormap colormap = MakeDefaultColormap();

    IRasterDiscreteColorRenderer renderer = new RasterDiscreteColorRenderer();
    renderer.Colormap = colormap;
    return (IRasterRenderer) renderer;
}

public IRasterColormap MakeDefaultColormap()
{
    var clrString = DtmColorTable.GetClrAsString();
    var blues = new List<double>();
    var reds = new List<double>();
    var greens = new List<double>();
    using (var reader = new StringReader(clrString))
    {
        string line;
        while ((line = reader.ReadLine()) != null)
        {
            var vals = line.Split(' ');
            reds.Add(Int32.Parse(vals[1]) / 255.0);
            blues.Add(Int32.Parse(vals[2]) / 255.0);
            greens.Add(Int32.Parse(vals[3]) / 255.0);
        }
    }

    IRasterColormap colormap = new RasterColormap();
    colormap.BlueValues = blues.ToArray();
    colormap.RedValues = reds.ToArray();
    colormap.GreenValues = greens.ToArray();
    return colormap;
}

public static IMADtedLayer CreateMADtedLayer(IWorkspace workspace, string catalogName)
{
     var inputDatasetName = System.IO.Path.GetFileName(catalogName);

     // Open the raster catalog
     var rasterCatalog = ((IRasterWorkspaceEx) workspace).OpenRasterCatalog(inputDatasetName);

     // Create the MADtedLayer
     IMADtedLayer maDtedLayer = new MADtedLayer();
     if (!maDtedLayer.Setup((ITable) rasterCatalog)) return null;

     ((IGdbRasterCatalogLayer) maDtedLayer).Renderers.Insert(0, CreateDtedRenderer());
     maDtedLayer.UseUniformRenderer = true;
     maDtedLayer.DisplayElevation = true;
     maDtedLayer.ResamplingType = rstResamplingTypes.RSP_NearestNeighbor;
     ((IWireframeDisplayProps) maDtedLayer).DisplayWireframe =
            esriMAWireframeDisplayEnum.esriWireframeDisplayNone;

     return maDtedLayer;
}

Has anyone ever changed the rendere of a MADtedLayer (or a IGdbRasterCatalogLayer in general?)

share|improve this question
    
What version of ArcGIS for Desktop are you using to try and do this? –  PolyGeo Oct 7 '13 at 6:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.