[GIS] Setting a value on a raster where a polygon intersects cells

arcobjectsintersectionpolygonraster

I reviewed all of the supposed 'answers' and I just do not see that they really answer my question. Mostly because the ones I'm reading are setting values either inside or outside a boundary. So let me clarify:

We have a river that the coast guard travels. An analyst indicates that halfway up the river, for a distance spanning one third the area is a delay. This delay represents the need for the boats to go through a lock. Since each cell in the current hydrography = the seconds it takes to traverse 1 meter, our approach which would be closest to accurate is to take the delay time halved, set the outer area to that value, set the remaining area to 1 (since the boat can traverse that region it cannot be set to NoData). Now by doing that I do not have to figure out which direction the boat is travelling through the polygon. Cost Distance should move the boat through the first cell, a general straight path through the '1' valued cells, then the last cell. Thus approximating the total delay time.

The polygon, after applying to the hydrography, becomes an outline of the river areas involved. The edge of that polygon must be set to delay-time / 2. All other cells inside must be set to 1.

My current workflow starts once the polygon raster has been extracted from the hydrography:

I do a RasterReclassOp.ReclassByRemap to set the polygon raster to the value of 1
I get the new polygon from the raster shape using RasterToPolygon
Now at this point I want to pass the polygon and the 'polygon raster' and set just the outside edge of that raster to the new value delay/2. I have seen this method but cannot remember what it is called. It does not involve conditional operators or anything else.

I remember the call was something like tool(polygon, value, raster) and every cell that the polygon touched or intersected would be set to 'value' in the raster.

The attached image shows what I am talking about. The dark green area will be set to seconds per meter * 1000. usually around 50. The orange line for a 2 hour delay would be set to 60*60*1000. The inner area (pink) would be set to 1.

I have done a bit of searching and cannot find an answer here. I just need to know the tool that sets that outer edge to a fixed value.

enter image description here

Best Answer

So here is the code that I think does the process. I found I could call Boundary off of the polygon without the polygon->line conversion.

    private static RasterDataset ApplyDelayZone(int baseTime, int delay, IGeoDataset delayZone, RasterDataset workarea)
    {
        // set polygon raster area to 1
        IReclassOp reclassOp = new RasterReclassOpClass();
        INumberRemap numberRemap = new NumberRemapClass();
        IRemap remap = (IRemap) numberRemap;
        numberRemap.MapValue(Convert.ToDouble(baseTime), 1);
        reclassOp.ReclassByRemap(delayZone, remap, true);

        // Get the polygon for the perimeter
        RasterDataset holdarea = workarea;
        ESRI.ArcGIS.ConversionTools.RasterToPolygon rtpConverter = new RasterToPolygon();
        Polygon donut = new PolygonClass();
        rtpConverter.in_raster = delayZone;
        rtpConverter.out_polygon_features = donut;
        RunTool(rtpConverter, true);

        //create a buffer around the polygon
        ITopologicalOperator op = (ITopologicalOperator)donut;
        IGeometry result = op.Buffer(0.5);

        // extract this polygon from the raster
        IExtractionOp2 exop = new RasterExtractionOpClass();
        IGeoDataset smallRaster = exop.Polygon((IGeoDataset)workarea, (IPolygon)result, true);

        // set the delay time in the 'donut' area
        numberRemap = new NumberRemapClass();
        remap = (IRemap)numberRemap;
        numberRemap.MapValue(Convert.ToDouble(baseTime), delay / 2);
        reclassOp.ReclassByRemap(smallRaster, remap, true);

        // combine the two rasters
        IGeoDataset smallDataset = (IGeoDataset)((IRaster2)(IRaster)smallRaster).RasterDataset;
        MosaicToNewRaster mtnrOne = new MosaicToNewRaster
        {
            input_rasters = new object[]{delayZone, smallDataset},
            number_of_bands = 1,
            output_raster_dataset = delayZone,
            mosaic_method="LAST"
        };
        RunTool(mtnrOne, true);

        // then combine the delay with the entire raster
        mtnrOne = new MosaicToNewRaster
        {
            input_rasters = new object[]{workarea, delayZone},
            number_of_bands = 1,
            output_raster_dataset = workarea,
            mosaic_method = "LAST"
        };

        return workarea;
    }