[GRASS-user] shortest distance using cost between centroid/lines

Dylan Beaudette dylan.beaudette at gmail.com
Sun Apr 8 19:08:53 EDT 2007


Hi Brandon,

On 4/8/07, Brandon M. Gabler <bgabler at email.arizona.edu> wrote:
> A problem with which I am currently working relates to the r.walk feature,
> for calculating anisotropic movement cost between two points, and
> v.distance, for calculating the shortest distance between my archaeological
> sites (areas) and river drainages (represented as lines). I could convert
> everything to raster data, if that improves the ability to calculate what I
> am interested in, but that's a different story, and not worth noting right
> now...what I need to do has not been described by any of the available
> examples and questions, or maybe I am still not comprehending how to do it
> properly, but here is the issue:
>

Interesting problem.

> I want to find the shortest distance between an archaeological site and a
> drainage. I do NOT want to specify to which drainage one should look from
> each site, because I want it to be the least cost to get to a source of
> water. I suppose that technically I would not NEED anisotropic modeling,
> because the trips would be round trip, but I still would prefer to do this
> with anisotropic distances because down the road I may want distances
> calculated from one site, to a drainage, to a different site, and back to
> the original site (for example, total shortest distance from a pueblo to a
> river to a grid garden back to the pueblo).

I have worked a bit with r.cost / r.drain analizing the cost moving
between a trail and a set of points off-traill. If you look at the
manual page for r.cost, it is possible to use an input raster as a set
of starting points
(http://169.237.35.250/~dylan/temp/r.cost_example.png). If you do your
analysis backwards from drainages to your sites, I think that you can
use r.cost to get a resonable answer.

Here is how I would approach it;

1. identify a vector drainage layer, and convert to raster at a
suitible resolution
g.region
r.to.vect

2. identify your archealogical sites

3. use r.cost to compute the cumulative cost surface- use the
appropriate cost surface: distance, slope, or perhaps a surrogate for
3D distance combining planar distance with the local slope * .

* use the slope and cell size to compute the 3d length across a single cell:
r.mapcalc "z = 1 / cos(slope_angle)"
accumulate z-cost, and then convert to meters :
dist_3d_meters = z-cost * (ewres()+nsres())/2.0

4. pickup the cumulative cost at each point with v.what.rast

5. ???

6. profit

Here is an example with spearfish60:

g.region vect=roads res=100 -a
v.to.rast in=roads out=roads.rast use=val val=1
r.cost -k in=slope out=cost start_rast=roads.rast
v.db.addcol archsites columns='cost double'
v.what.rast archsites column=cost raster=cost
echo 'select * from archsites order by cost asc' | db.select

# cleanup
g.remove rast=cost
v.db.dropcol archsites col=cost


will that work?

note that the 3D distance seems correct, but you might want some
verification from a specialist.

Cheers,

dylan


> Therefore, the requirement of r.walk and r.cost to specify start/stop points
> is not good for me.
>
> Obviously, first I need a cost surface. For ease of argument, I'm going to
> stick with slope and only slope right now. So, I have these data:
>
> All_sites - vector, polygons of sites (I also have a point version of this
> map, where the centroids of the areas were converted to a point topology)
> Drainages - vector, lines of drainages
> DEM_16 - elevation at 16 foot resolution
> Slope_16 - slope at 16 foot resolution (calculated from DEM)
> Aspect_16 - aspect at 16 foot resolution (also calc. from DEM)
>
> Once I have identified the closest drainage based on least-cost-distance, I
> want to upload two columns to the All_sites db, one for the distance, one
> for the drainage identified as closest - just like v.distance allows.
>
> r.drain does some of what I want, but not completely. I have been staring at
> the manual pages and searching the archives for a while now, and it really
> seems that everyone has specified start/stop points in mind (all of the talk
> about Tobler's hiking function a few months back, for example).
>
> Chances are that I am making this more complicated than necessary, but I
> hoped there could be some sort of solution. If specifying a destination is
> really the way I have to go, I can convert my drainage lines into points,
> and just find the shortest distance to one of those points via a cost
> surface. But again, I still don't know how to let GRASS decide which of 2
> lines, points, etc. are closer (via a cost surface) and then have it give me
> that least-cost distance.
>
> Any ideas?
>
> Thanks much in advance,
> Brandon
>
> _______________________
> Brandon M. Gabler
> Doctoral Candidate
> Department of Anthropology
> University of Arizona
> Tucson, AZ 85721
> Phone: (520) 621-8455
> Fax: (520) 621-2088
> bgabler at email.arizona.edu
>
> "Who? When? Whither? are the questions with which the archaeologist
> challenges the refuse heaps, scattered potsherds, and broken shafts, to tell
> of the builders who came and lived and went their way into the templed
> past." -- Edgar Lee Hewett, in Pajarito Plateau and its Ancient People, 1938
>
>
> _______________________________________________
> grassuser mailing list
> grassuser at grass.itc.it
> http://grass.itc.it/mailman/listinfo/grassuser
>
>




More information about the grass-user mailing list