0

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

6
  • Why not buffer the line by half a pixel then poly to raster and mosaic/con the result back in? ESRI raster handling doesn't readily allow changing values in a raster and like most tools input(s) -> output. This is intentional, so in the worst case you've still got your original. Commented May 12, 2014 at 22:05
  • So let me get this right. I have a raster defined for some polygon. I reduce the polygon by 1 and get a buffer to cut out the outer rim, then set that rim to the value I need? That could work, though process time may be a bit....bogged down. Commented May 12, 2014 at 22:28
  • At some stage you will have the polygon in question, use polygon to line help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//… or feature to line help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//… to extract the boundary, buffer it by half a pixel and polygon to raster, then mosaic the original, the polygon raster and the polygon boundary buffer raster in the correct order and you will have something that looks like the picture. Commented May 12, 2014 at 22:44
  • So I began testing and my call to do a RasterToPolygon blew up because it is expecting a FeatureClass instead of a Polygon. (I hate ESRI programs!) So how do I go about creating a FeatureClass on the fly?? I prefer to avoid file I/O and stay inmemory instead since this is a service. Commented May 16, 2014 at 19:02
  • Does it expect a container to put the features in? To make a new (empty) feature class call IFeatureWorkspace.CreateFeatureClass resources.arcgis.com/en/help/arcobjects-net/componenthelp/… which you can use InMemoryWorkspace resources.arcgis.com/en/help/arcobjects-net/componenthelp/…. There is a few critical steps to creating one edndoc.esri.com/arcobjects/9.2/NET/… as a reference. It's 9.2 but hasn't changed much. Commented May 16, 2014 at 20:45

1 Answer 1

0

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;
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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