<div dir="ltr"><div>I think r.walk was not written for negative friction and while I imagine some small (in absolute sense) negative values may work, your negative values are pretty extreme, meaning the resulting travel time through a cell would be negative. That can cause all kinds of issues in the algorithm. So I would say friction should not be negative. I am not sure I would check that in the code, because you would need to check that for each cell and I think it's unnecessary overhead. Maybe just adding a note to documentation may be enough. I haven't looked into the code itself, so this is just my guess.</div><div><br></div><div>Anna</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Nov 28, 2023 at 5:48 PM Michael Barton via grass-user <<a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div>
<div>In teaching a class about modeling movement, we talked about how to represent a cost surface when some areas of terrain (e.g., water or paved roads), could be crossed more rapidly than walking across unmodified topography. Since a friction map for r.walk
adds cost in seconds/meter to the cost of walking across unmodified terrain, I wondered if a friction map with **negative costs** would decrease the movement costs across a landscape. </div>
<div><br>
</div>
<div>Using the SC demo data set, I tried this with a set of maps I prepared for class. Previously, I had created a friction map from the landclass96 map such that cells with water (class 20) have a value of 90 sec/m, dense vegetation (classes 7-19) have a value
of 20 sec/m, and the rest of the cells have a value of 0 sec/m. I generated a cost surface with r.walk using elevation and this friction map with a starting point from the Dorothea Dix Hospital. </div>
<div><br>
</div>
<div>r.walk --overwrite -k elevation=elevation@PERMANENT friction=landclass96_friction output=dd_hospital_seconds_friction outdir=dd_hospital_directions_friction start_points=DD_hospital memory=1000</div>
<div><br>
</div>
<div>This behaved as expected and created a cost surface that represented different degrees of difficulty in crossing vegetated and inundated terrain. </div>
<div><br>
</div>
<div>To explore what would happen with a friction surface with negative numbers, I simply subtracted the previous friction map from 0 so that dense vegetation = -20, water = -90, and the rest of the cells = 0. Then I used it with r.walk and the elevation DEM. </div>
<div><br>
</div>
<div>r.walk -k elevation=elevation@PERMANENT friction=landclass96_friction_negative output=dd_hospital_seconds_negativefriction outdir=dd_hospital_directions_negativefriction start_points=DD_hospital memory=2000</div>
<div><br>
</div>
<div>There was no error, but the resulting cost surface is very strange. </div>
<div><br>
</div>
<div>The data range of the original cost surface with the positive values friction map is: </div>
<div><br>
</div>
<div>Range of data: min = 0 max = 103883.003593944 (max of 28.8 hours to reach the hospital given added costs of walking through dense vegetation or avoiding water). </div>
<div><br>
</div>
<div>However, the data range of the cost surface made with the friction map with negative values is completely weird. </div>
<div><br>
</div>
<div>Range of data: min = -166202271.811971 max = -154320.938078961 (-46167 to -43 hours)</div>
<div><br>
</div>
<div>Since a friction map simply adds cost to the cost surface, if a negative friction map did not work, I might expect it to raise an error or have no impact (values < 0 become 0). But the values in the resulting cost surface don't make any sense at all. </div>
<div><br>
</div>
<div>Does anyone have any thoughts on this? </div>
</div>
<div><br>
</div>
<div>I will try to attach attach the original friction map made from the SC landclass96 map, the cost surface made with elevation and friction map, and cost surface made with elevation and negative friction map. </div>
<div><br>
</div>
<div>Michael</div>
<div><br>
</div>
<div><u></u><u></u><u></u><u></u><u></u><u></u></div>
<div>
<div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div dir="auto" style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div dir="auto" style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div dir="auto" style="text-align:start;text-indent:0px">
<div style="text-align:start;text-indent:0px">
<div style="text-align:start;text-indent:0px">
<div style="text-align:start;text-indent:0px">
<div style="text-align:-webkit-auto;text-indent:0px">
<span style="border-collapse:separate;border-spacing:0px">
<div style="overflow-wrap: break-word;">
<span style="border-collapse:separate;text-indent:0px;border-spacing:0px">
<div style="overflow-wrap: break-word;">
<span style="border-collapse:separate;text-indent:0px;border-spacing:0px">
<div style="overflow-wrap: break-word;">
<span style="border-collapse:separate;text-indent:0px;border-spacing:0px">
<div style="overflow-wrap: break-word;">
<span style="border-collapse:separate;text-indent:0px;border-spacing:0px">
<div style="overflow-wrap: break-word;">
<span style="border-collapse:separate;text-indent:0px;border-spacing:0px">
<div style="overflow-wrap: break-word;">
<span style="border-collapse:separate;text-indent:0px;border-spacing:0px">
<div style="overflow-wrap: break-word;">
<span style="border-collapse:separate;text-indent:0px;border-spacing:0px">
<div style="overflow-wrap: break-word;">
<font>
<div style="letter-spacing:normal;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;font-variant-ligatures:normal;font-variant-east-asian:normal;line-height:normal">
<font color="#929292" face="Calibri" style="font-style:normal;font-size:11px">_____________________________</font></div>
<div style="font-variant-ligatures:normal;font-variant-east-asian:normal;line-height:normal">
<p style="margin-bottom:0in"><font color="#929292" face="Calibri" style="font-style:normal;font-size:11px"><font><span>C. Michael Barton<br>
Associate Director, School of Complex Adaptive Systems (</span></font><a href="https://scas.asu.edu/" target="_blank">https://scas.asu.edu</a><font><span>)<br>
Professor, School of Human Evolution & Social Change (<a href="https://shesc.asu.edu" target="_blank">https://shesc.asu.edu</a>)<br>
Director, Center for Social Dynamics & Complexity (<a href="https://complexity.asu.edu" target="_blank">https://complexity.asu.edu</a>)<br>
Arizona State University<br>
Tempe, AZ 85287-2701<br>
USA<br>
<br>
Executive Director, Open Modeling Foundation (</span></font><a href="https://openmodelingfoundation.github.io/" target="_blank">https://openmodelingfoundation.github.io</a><font><span>)<br>
Director, Network for Computational Modeling in Social & Ecological Sciences (<a href="https://comses.net" target="_blank">https://comses.net</a>)<br>
<br>
personal website: <a href="http://www.public.asu.edu/~cmbarton" target="_blank">http://www.public.asu.edu/~cmbarton</a> <br>
</span></font></font><br>
</p>
</div>
</font></div>
</span></div>
</span></div>
</span></div>
</span></div>
</span></div>
</span></div>
</span></div>
</span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
</div>
_______________________________________________<br>
grass-user mailing list<br>
<a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/grass-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
</blockquote></div></div>