After a great deal of research here is what is happening: We select two points on a hydrography map with an island inbetween. It is expected that the CostDistanceWithPolyline would return a line that traverses around the island. We are now finding that the Cost Array that is computed ignores the existance of SOME of our NoData areas, but not all of them! What is wrong here??? We cannot find the issue!!!

The hydrography map with island in question: note the value is NoData for a point I chose inside the island geometry. Hydrography map with Info display of NoData

The resulting shortest path. Kinda hard for a boat to do that! Path thru the island

The cost array and it's value at the island location. cost array with Nodata ignored!

The call is so stupid for getting a cost array that I cannot determine how the call could be messed up. As per code that ESRI did for us: we pass the hydrography map, the target point, and call GetCostDistanceFull

Here is our call to get the cost distance and backlink arrays.

    private static IGeoDataset[] ComputeFullRaster(IFeatureClass origin, RasterDataset costArray, IGPMessages messages)
        List<IGeoDataset> results = new List<IGeoDataset>();
        IDistanceOp distanceOp = new RasterDistanceOpClass();

        // Create the cost distance
        messages.AddMessage("Creating the distance cost raster...");
        object objectMissing = Type.Missing;

        results.Add( distanceOp.CostDistanceFull(
            (IGeoDataset)origin, (IGeoDataset)costArray, 
            true, false,
            false, ref objectMissing, ref objectMissing) );
        messages.AddMessage("Creating the backlink cost raster...");
            (IGeoDataset)origin, (IGeoDataset)costArray,
            false, true,
            false, ref objectMissing, ref objectMissing));
        return results.ToArray();

It turns out the problem was that we are displaying the raster files from the database. We are working with the rasters inside the RasterDataset. The rasters in that were very old and invalid. Once I rebuilt the raster dataset with the rasters we now use, the data was processed correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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