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.

How can I set the min and max values for the stretch type "Percent Clip" in arcobjects?

It's possible to set the Stretch type:

rasterStretch.StretchType = esriRasterStretchTypesEnum.esriRasterStretch_PercentMinimumMaximum;

But I have no idea how I can set the min and max values (like in the Properties Dialog of ArcMap).

Layer Properties with Stretch type Percent Clip and min/max percent values

share|improve this question
    
what exactly are you trying to do? Can you include more code than just one line, to give us more context? –  Devdatta Tengshe Apr 10 '13 at 11:29
    
I want to pull out functionality from the Layer Properties dialog and put it in a custom dockable window. Thus, the user can change (raster) properties for more than one layer at the same time. –  Saleika Apr 10 '13 at 12:56
    
A screen capture of the Layer Properties dialog you are describing would be helpful. –  Kirk Kuykendall May 10 '13 at 13:21

1 Answer 1

Looks like you want the IRasterStretchMinMax Interface. Use CustomStretchMin and CustomStretchMax to set the min/max:

public void StretchRenderer(ILayer layer, IMxDocument mxDoc)
        {
            IRasterLayer pRasterLayer = (IRasterLayer)layer;
            try
            {
                IRasterStretchColorRampRenderer pRasterStretchColorRampRenderer;
                pRasterStretchColorRampRenderer = new RasterStretchColorRampRendererClass();
                // Setup the stretch
                IRasterStretch pRasterStretch;
                pRasterStretch = (IRasterStretch)pRasterStretchColorRampRenderer;
                pRasterStretch.StretchType = esriRasterStretchTypesEnum.esriRasterStretch_MinimumMaximum;
                // Set the stretch max/min - 0/254 in this case
                IRasterStretchMinMax pRasterStretchMinMax;
                pRasterStretchMinMax = (IRasterStretchMinMax)pRasterStretchColorRampRenderer;
                pRasterStretchMinMax.UseCustomStretchMinMax = true;
                pRasterStretchMinMax.CustomStretchMin = 0;
                pRasterStretchMinMax.CustomStretchMax = 254;
                // Apply the renderer
                pRasterLayer.Renderer = (IRasterRenderer)pRasterStretchColorRampRenderer;
                // Collapse the legends on each raster
                ILegendInfo legendInfo = (ILegendInfo)pRasterLayer.Renderer;
                ILegendGroup legendGroup = (ILegendGroup)legendInfo.get_LegendGroup(0);
                legendGroup.Visible = false;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
share|improve this answer
    
Thank you for your post. But it's not exactly what I'm looking for. The CustomStretchMin and CustomStretchMax Values are allready Pixel values, while the input for Percent Clip are percent values. I hope there is an easier way than to calculate the CustomStretchMin and CustomStretchMax Values using histogram information and min/max percent values. E.g. for the stretch type esriRasterStretchTypesEnum.esriRasterStretch_StandardDeviations exists a property called IRasterStretch2.StandardDeviationsParam. –  Saleika Apr 10 '13 at 13:30

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.