[GRASS-user] distance from extent to origin cost surfaces
Dylan Beaudette
dylan.beaudette at gmail.com
Sun Mar 30 15:51:25 EDT 2008
On Sunday 30 March 2008, Jason Jorgenson wrote:
> Hi Dylan. Ok, so maybe some background... I use r.walk to create a
> cost surface using an archaeological site as the origin. I determine
> through diet analysis how much food the ancient settlement would have
> required, and from that how much land they needed. I then identify
> that area of suitable land surrounding the site by starting at the
> origin of the r.walk cost surface and moving outwards until enough
> land is contained. lets say the cost surface's range is 0-72000 and
> the amount of land is contained at an extent of 36000 on the cost
> surface. I want to know what the actual distance range that people
> had to travel to reach the outermomst extent of their catchment. The
> extent is equal all around obviously, at 36000 seconds or 5 hours, but
> it would be nice to know the min/max distance as well. Not necessary
> to know path routes or anything. Simple distance is what I am after.
> Hope this makes more sense now.
>
> Kindest regards
>
> Jason
Here is how I would approach this, using the spearfish dataset:
# set region, and then zoom in a bit
g.region rast=elevation.dem -p
# compute a "cost" surface -- slope
r.slope.aspect elev=elevation.dem slope=slope format=percent --o
# compute the accumulated cost surface from some point
r.cost -k in=slope out=cost coordinate=595365.16129032,4922219.67741936
# set the critical, accumulated cost value:
r.mapcalc "cost_bin = if(cost <= 580.169678, 1, null())"
# grow this max accumulated cost surface by 1 cell:
r.grow in=cost_bin out=cost_bin_plus_1 radius=1
# identify the perimeter of the critical cost perimeter:
r.mapcalc "cost_perim = if(isnull(cost_bin_plus_1) == isnull(cost_bin),
null(), 1)"
# now we need an accumulated distance map from the point of origin:
# make a map of 1's to count by
r.mapcalc "one = 1"
# accumulate distance from starting point:
# note that this is now 2D distance
r.cost -k in=one out=accum_dist coordinate=595365.16129032,4922219.67741936
# compute some stats on the range in distance, from starting point, to
perimeter of the critical accumulated cost surface (in this case slope
percent):
# use the perimeter rast as a MASK
g.rename rast=cost_perim,MASK
# compute stats:
r.univar map=accum_dist
total null and non-null cells: 37515
total null cells: 37013
Of the non-null cells:
----------------------
n: 502
minimum: 31
maximum: 100
range: 69
mean: 58.8526
mean of absolute values: 58.8526
standard deviation: 18.1618
variance: 329.851
variation coefficient: 30.8598 %
sum: 29544
This is slightly incorrect -- as we are growing the cost surface to compute
the perimeter, when we should be shrinking it. However it appears that r.grow
cannot use a negative radius.
Does this address the problem at hand?
Cheers,
Dylan
> On Sun, Mar 30, 2008 at 1:11 AM, Dylan Beaudette
>
> <dylan.beaudette at gmail.com> wrote:
> > On Saturday 29 March 2008, Jason Jorgenson wrote:
> > > Hi everyone. I am trying to determine the minimum and maximum
> > > distance from the outermost extents of a cost surface (which I
> > > genereated with r.walk) back to the origin. Is there a way to do
> > > this?
> > >
> > > Jason
> >
> > can you elaborate?
> >
> > usually r.drain is used in conjunction with r.walk / r.cost to find
> > the "least-cost" path. Not sure how you would find the "most-cost" (?)
> > path.
> >
> > Cheers,
> >
> > Dylan
> >
> > --
> > Dylan Beaudette
> > Soil Resource Laboratory
> > http://casoilresource.lawr.ucdavis.edu/
> > University of California at Davis
> > 530.754.7341
--
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341
More information about the grass-user
mailing list