Using cost array to act as effect of speed on movement

538
3
09-09-2013 07:30 AM
MichaelEber
Occasional Contributor
I'm new to ArcGIS programming and looking for some assistance here.  We are running ArcGIS 10.1 server, Spacial Analysis for Raster Layers, and the 2500 version of ArcGIS explorer.

We are using a boats' area of responsibility as a limiter for the distance it can respond to issues for 15 minute segments out to 90 minutes.  Today our response vectors are just running the boat flat out at full speed without any external influences.  This may be fine where the AOR is on the ocean, but not good in rivers.  We pass a value which is the distance covered in each segment of time minus the time it takes for the crew to initially respond based on day or nighttime events.

We need to be able to take into account no wake zones, speed limits, and the possibility that a barge is blocking the path and needs to be carefully passed before returning to full speed.

The current server code does generate a raster (I assume this is the full area of response) passing the values for the 6 segments.  Then they create a cost array (and I believe this is where I inject the speed limits, blockages, etc) and then do the final call to get the polygons to draw.

So I wondering how to set up this cost array so that the values act as speed limiters on the process.  So showing below:

Max speed 46 knots
Distance covered in 15 minutes

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

                |   20 knot limit  |

Final vector (source raster array with speed limit applied in cost raster array) should be

xxxxxxxxxxxxxxxxxxxxxxx

Since the two arrays are added together do I set the cost array to -26 for that area?  The documentation only talks of positive values in the cost array.

Thanks for any assistance anyone can provide.

Michael
0 Kudos
3 Replies
XanderBakker
Esri Esteemed Contributor
Hi Michael,

If I understand you correctly you want to setup a cost raster to include speed. Performing a cost distance calculation is not more than a normal distance calculation where the distance is converted to travel cost. It is possible to obtain travel times if the cost raster represents the number of time units per distance unit (inverse speed).

Let�??s say you are working with a raster resolution of 100m. For a certain cell "A" the speed is 46 knots. 46 knots is about 23.7 m/s. The cost of that cell shout be 1/23.7 (s/m). When traveling horizontally or vertically over that cell the distance (100m) will be multiplied by the cost (1/23.7), which is results in around 4.2 seconds. So, it will take 4.2 seconds to travel over that cell.

For those cells that have a different max speed like 20 knots, the cost raster will have a different (higher) value, since the "costs" is higher to travel over that cell.  20kn * 0.514444 = 10.3m/s. The cost will be 1/10.3 (s/m). Travel over this cell horizontally or vertically will take 100m*1/10.3s/m = 9.7 seconds.

After the cost distance calculation you can reclassify your raster in the time zones needed.

More info on how cost distance works:
http://resources.arcgis.com/en/help/main/10.1/index.html#/How_the_cost_distance_tools_work/009z00000...

Kind regards,

Xander
0 Kudos
MichaelEber
Occasional Contributor
Yes, that is what I want to do.  And I read the article you included at least 3 or 4 times.  Unfortunately that help file talks about the concept but no the implementation.  For example: the code we inherited is making a call that creates a number of polygons for 15, 30, 45, and 90 minute response time zones.  but this call is made using maximum speed of the boat.

The code never actually applies any cost array and makes the call I found in one of the API examples.

Now the API example shows a convenient method that takes in all of the parameters of the call and returns the result of the call.  But it does not show the intermediate step which is computing the cost factor array.  And since I'm new to ArcGIS I'm not even sure what a raster is.  🙂  I've only known rasters as a type of graphics.

So if I take the raster from the first call, I have the maximum distance the boat can go with no speed limits or blockages.  I suppose (think) the next step would be to copy that raster to a cost raster and null the whole thing.  But I cannot see anything anywhere in my searching as to how I programmatically set the speed values as you had indicated.  And it gets more complex as we layer more items onto it.  For example taking wind into account (a 10 mph wind would have little impact on a cutter but a 20 mph wind would) and then adding that storm conditions occur which  would layer a sine wave algorithm along the wind vector creating "uphill" and "downhill" movement of the boat as well.

Everytime I Google the topic I get the documentation for the ArcGIS client or I get that theoretical discussion you included the link of.  I don't get any documentation on the C# code for creating those values programmatically.  Do you see the distance and what I'm trying to get an answer to?

Is the raster like an array?  Do I just iterate through each element and set a value?  If so I do I know the orientation (am I at the cell in the northern or southern location of the raster?) of that cell?  I can whip out creating and populating an array with values no problem.  But a raster???  And how do I know the resolution of the raster that was sent to me in that first call?

Michael
0 Kudos
XanderBakker
Esri Esteemed Contributor

Now the API example shows a convenient method that takes in all of the parameters of the call and returns the result of the call.  But it does not show the intermediate step which is computing the cost factor array.  And since I'm new to ArcGIS I'm not even sure what a raster is.  🙂  I've only known rasters as a type of graphics.


Hi  Michael,

That's quite a challenge you're facing... Let's start with the definition of a raster. I Think the link to the page "What is raster data" should get you started on that topic (I've included links to ArcGIS Help 10.0 and 10.2, since I don't know what version you're working with):
http://resources.arcgis.com/en/help/main/10.2/index.html#//009t00000002000000  10.2
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/What_is_raster_data/009t00000002000000... 10.0



Everytime I Google the topic I get the documentation for the ArcGIS client or I get that theoretical discussion you included the link of.  I don't get any documentation on the C# code for creating those values programmatically.  Do you see the distance and what I'm trying to get an answer to?


Since you what to know how you can create raster data programmatically, the link to this 10.0 Help page ("Performing a spatial analysis operation using objects") will provide you information on how to access raster objects from code and process them:
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/Performing_a_spatial_an...

In order to analyze raster data you will probably need a Spatial Analyst extension. The 10.0 ArcObjects Library Reference (SpatialAnalyst) can be found here:
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/ESRI_ArcGIS_SpatialAnaly...



But a raster???  And how do I know the resolution of the raster that was sent to me in that first call?


IRasterProps::MeanCellSize (ESRI.ArcGIS.DataSourcesRaster) is used to access the cell size.
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#/IRasterProps_Interface/0...


To create the cost raster (speed to cost conversion) you will probably use a raster or vector layer containing information on speeds. If this information is static, you can do this manually one time, but if this is dynamic data you should probably do this by code.

From vector (polygons with attributes on speed), first calculate a new column transforming speed to cost as explained earlier. Then convert the features to raster. See snippet here:
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/index.html#//00490000000z000000

From raster data you would probably use some raster algebra to obtain the desired cost raster. Snippet here:
http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//000100000165000000


I think you might obtain more helpful information if you post this thread in the ArcObjects forum:
http://forums.arcgis.com/forums/20-ArcObjects-SDKs


Hope this gets you started.

Kind regards,

Xander
0 Kudos