Re: [GRASS-dev] [GRASS-user] cost surface with negative friction odd behavior

2023-11-30 Thread Michael Barton via grass-dev
Done
_

C. Michael Barton
Associate Director, School of Complex Adaptive Systems 
(https://scas.asu.edu)
Professor, School of Human Evolution & Social Change (https://shesc.asu.edu)
Director, Center for Social Dynamics & Complexity (https://complexity.asu.edu)
Arizona State University
Tempe, AZ 85287-2701
USA

Executive Director, Open Modeling Foundation 
(https://openmodelingfoundation.github.io)
Director, Network for Computational Modeling in Social & Ecological Sciences 
(https://comses.net)

personal website: http://www.public.asu.edu/~cmbarton


On Nov 30, 2023, at 11:29 AM, Anna Petrášová  wrote:

Michael, could you please create a PR for the documentation?

On Wed, Nov 29, 2023 at 3:56 PM Michael Barton via grass-user 
mailto:grass-u...@lists.osgeo.org>> wrote:
Thanks Anna and Doug,

I did not expect it to work (thought it would be useful if it did). Rather I 
was surprised by the fact that r.walk DID run and that it gave very odd results.

Adding to the docs is a good idea. Even better would also to have a friction 
map with a negative value (min<0) raise an error in r.walk, saying that all 
values in a friction map must be ≥ 0

Michael
_

C. Michael Barton
Associate Director, School of Complex Adaptive Systems 
(https://scas.asu.edu)
Professor, School of Human Evolution & Social Change 
(https://shesc.asu.edu)
Director, Center for Social Dynamics & Complexity 
(https://complexity.asu.edu)
Arizona State University
Tempe, AZ 85287-2701
USA

Executive Director, Open Modeling Foundation 
(https://openmodelingfoundation.github.io)
Director, Network for Computational Modeling in Social & Ecological Sciences 
(https://comses.net)

personal website: http://www.public.asu.edu/~cmbarton


On Nov 29, 2023, at 1:00 PM, 
grass-user-requ...@lists.osgeo.org 
wrote:

Date: Wed, 29 Nov 2023 10:17:19 -0500
From: Anna Petr??ov? mailto:kratocha...@gmail.com>>
To: Michael Barton mailto:michael.bar...@asu.edu>>
Cc: GRASS developers 
mailto:grass-dev@lists.osgeo.org>>, GRASS user list
mailto:grass-u...@lists.osgeo.org>>
Subject: Re: [GRASS-user] cost surface with negative friction odd
behavior
Message-ID:
mailto:cae0edeofhx75u2r6qc8ek5p8czg2cd1iwr8j3vx8qiwwe8z...@mail.gmail.com>>
Content-Type: text/plain; charset="utf-8"

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.

Anna

On Tue, Nov 28, 2023 at 5:48?PM Michael Barton via grass-user <
grass-u...@lists.osgeo.org> wrote:

___
grass-user mailing list
grass-u...@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

___
grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev


Re: [GRASS-dev] [GRASS-user] cost surface with negative friction odd behavior

2023-11-30 Thread Anna Petrášová via grass-dev
Michael, could you please create a PR for the documentation?

On Wed, Nov 29, 2023 at 3:56 PM Michael Barton via grass-user <
grass-u...@lists.osgeo.org> wrote:

> Thanks Anna and Doug,
>
> I did not expect it to work (thought it would be useful if it did). Rather
> I was surprised by the fact that r.walk DID run and that it gave very odd
> results.
>
> Adding to the docs is a good idea. Even better would also to have a
> friction map with a negative value (min<0) raise an error in r.walk, saying
> that all values in a friction map must be ≥ 0
>
> Michael
> _
>
> C. Michael Barton
> Associate Director, School of Complex Adaptive Systems (
> https://scas.asu.edu)
> Professor, School of Human Evolution & Social Change (
> https://shesc.asu.edu)
> Director, Center for Social Dynamics & Complexity (
> https://complexity.asu.edu)
> Arizona State University
> Tempe, AZ 85287-2701
> USA
>
> Executive Director, Open Modeling Foundation (
> https://openmodelingfoundation.github.io)
> Director, Network for Computational Modeling in Social & Ecological
> Sciences (https://comses.net)
>
> personal website: http://www.public.asu.edu/~cmbarton
>
>
> On Nov 29, 2023, at 1:00 PM, grass-user-requ...@lists.osgeo.org wrote:
>
> Date: Wed, 29 Nov 2023 10:17:19 -0500
> From: Anna Petr??ov? 
> To: Michael Barton 
> Cc: GRASS developers , GRASS user list
> 
> Subject: Re: [GRASS-user] cost surface with negative friction odd
> behavior
> Message-ID:
> 
> Content-Type: text/plain; charset="utf-8"
>
> 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.
>
> Anna
>
> On Tue, Nov 28, 2023 at 5:48?PM Michael Barton via grass-user <
> grass-u...@lists.osgeo.org> wrote:
>
>
> ___
> grass-user mailing list
> grass-u...@lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-user
>
___
grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev


Re: [GRASS-dev] [GRASS-user] cost surface with negative friction odd behavior

2023-11-29 Thread Anna Petrášová via grass-dev
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.

Anna

On Tue, Nov 28, 2023 at 5:48 PM Michael Barton via grass-user <
grass-u...@lists.osgeo.org> wrote:

> 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.
>
> 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.
>
> 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
>
> This behaved as expected and created a cost surface that represented
> different degrees of difficulty in crossing vegetated and inundated
> terrain.
>
> 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.
>
> 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
>
> There was no error, but the resulting cost surface is very strange.
>
> The data range of the original cost surface with the positive values
> friction map is:
>
> 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).
>
> However, the data range of the cost surface made with the friction map
> with negative values is completely weird.
>
> Range of data:min = -166202271.811971  max = -154320.938078961 (-46167
> to -43 hours)
>
> 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.
>
> Does anyone have any thoughts on this?
>
> 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.
>
> Michael
>
> _
>
> C. Michael Barton
> Associate Director, School of Complex Adaptive Systems (
> https://scas.asu.edu)
> Professor, School of Human Evolution & Social Change (
> https://shesc.asu.edu)
> Director, Center for Social Dynamics & Complexity (
> https://complexity.asu.edu)
> Arizona State University
> Tempe, AZ 85287-2701
> USA
>
> Executive Director, Open Modeling Foundation (
> https://openmodelingfoundation.github.io)
> Director, Network for Computational Modeling in Social & Ecological
> Sciences (https://comses.net)
>
> personal website: http://www.public.asu.edu/~cmbarton
>
>
> ___
> grass-user mailing list
> grass-u...@lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/grass-user
>
___
grass-dev mailing list
grass-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-dev