[R-sig-Geo] gdistance: working with vector speed data in two direction

tf at devmag.net tf at devmag.net
Fri Dec 9 22:08:36 CET 2011



Dear Jacob, dear all,

thaks for the hint towards the adjacent() function. I got "somewhere"  
using this.

Using the wind-vector data I calculated for each adjacent cell the  
speed based on my very simplistic modelling of sailing.


The structure is a dataframe that looks for example as follows:

from   to   speed
2000  1998   0
2000  1999   1.2223
2000  2001   2.8972


so I basically just added a speed vector to the vector of adjacencies.  
If a ship can not go somewhere, the speed is set to 0 for that  
adjacency.

I now was wondering how I can get this into the transition-layer  
format so that I can use the Diijsktra implementation in that package?

I want to see how well this simplistic modelling works, before adding  
more layers of sophistication.


Thanks a lot for your help and hints,

best Thiemo



Zitat von Jacob van Etten <jacobvanetten at yahoo.com>:

> Hi Thiemo,
>
> This is something beyond the transition() function. You probably  
> need to look at all 8 directions separately and then sum the
> TransitionLayer objects.
>
>
> You could achieve that by looking at the
> adjacent() function in raster to analyze connected cells in each direction
> separately.
>
>
> I think that not going at more than 90 degrees against the wind  
> would oversimplify too much and is not necessary.
>
>
> You will need to work out the mathematics to do this. I think that  
> the website I gave you below gives all the clues you need to  
> approximate sailing boat speed.
>
>
> Best,
>
> Jacob.
>
>
>
> ________________________________
>  From: "tf at devmag.net" <tf at devmag.net>
> To: Jacob van Etten <jacobvanetten at yahoo.com>
> Cc: "r-sig-geo at r-project.org" <r-sig-geo at r-project.org>
> Sent: Thursday, 8 December 2011, 15:04
> Subject: Re: [R-sig-Geo] gdistance: working with vector speed data  
> in two direction
>
>
> Dear Jacob,
>
>
> thank you for your prompt response. I am not sure whether I really  
> understand the material in the link. This is alll considering the  
> case when one is aboard a ship and measures an apparent wind  
> direction and a given speed of the boat.
>
> Essentially, what I have is the direction and strength of the wind  
> and I want to transform this into a speed of a boat going in a  
> certain direction.
>
> The example I was thinking about was something very simplistic:
>
> Think of the boat being in the center of a 9x9 grid and hence  
> technically it may be able to move into all 8 cells.  So lets just  
> assume that the course the ship can take are courses -180 -135 -90  
> -45 0  45  90  135 180  degrees (by assumption), where a course 0  
> degrees means going to the center row rightmost cell.
>
> Next I assume that the ship "does not accumulate speed", going from  
> cell to cell - think of this representing the water friction.
>
> Also for simplicity I assume that the ship can sail at most at 90  
> degree angles to the wind (in either direction), so for wind coming  
> at angle alpha, the ships courses can range from alpha-90 to alpha+90.
>
> I am really not sure how realistic this is, I guess it corresponds  
> to the ship having a drag and a lift sail, see
>
> http://terrytao.wordpress.com/2009/03/23/sailing-into-the-wind-or-faster-than-the-wind/
>
>
> I think these two features make the transition function less  
> straightforward. I just computed a simple example.
>
> Suppose the wind blows at 75 degree angle with speed 10 m/s.
>
> Now the ship wants to move into a 45 degree course to reach the  
> upper right cell. What is its speed?
>
> The angle between wind and ship course is 75 - 45 = 30 degree. Of  
> the 10 m/s wind going in direction 75 degree, only a portion is used  
> on the 45 degree course. This portion is:
>
> v = cos(30)*10 m/s
>
> For top center cell (90 degrees course)
> v = cos(90-75) * 10
> Top left cell: (135 degrees course)
> v = cos(135-75)*10
>
> The right center row cell (0 degree course)
> v = cos(75-0)) * 10
>
> The bottom row right cell as well as all other cells  can not be  
> reached, as the course angle abs(course - 75) > 90 degrees.
>
> So I need to assign these transitions speed 0.
>
>
> This is not what I had originally in mind, as its a crude  
> simplification but maybe its one on which I can iterate.
>
>
> The key question is now, how do I implement this? I dont quite  
> understand how I can define the transition function to use these  
> different course angles for the 8 adjacent cells - essentially, it  
> is a "different function" for each of the 8 adjacent cells.
>
>
> I hope this is a bit more clear, thank you very much for your help,
>
> best Thiemo
>
>
> Zitat von Jacob van Etten <jacobvanetten at yahoo.com>:
>
>> Dear Thiemo,
>>
>> Nice question.
>>
>>
>> The wind direction/speed would need to be converted into a cost or  
>> speed variable. This website explains how:
>>
>> http://sites.google.com/site/yoavraz2/sailingboatspeedvs.windspeed
>>
>> Best,
>>
>> Jacob.
>>
>>
>>
>> ________________________________
>>   From: "tf at devmag.net" <tf at devmag.net>
>> To: r-sig-geo at r-project.org
>> Sent: Thursday, 8 December 2011, 11:11
>> Subject: [R-sig-Geo] gdistance: working with vector speed data in  
>> two direction
>>
>> Dear all,
>>
>> I have the following problem.
>>
>> I managed to use the gdistance package to give me computations for  
>> shortest distances between two ocean points. I am working on a  
>> simple 1 degree grid for that and it works fine.
>>
>> However, now I want to incorporate something slightly more  
>> advanced. For each cell of the grid I have a wind vector with its  
>> horizontal and its vertical wind component; the units are speeds in  
>> meters per second, which can be positive / negative indicating the  
>> direction north/ south, east and west.
>>
>> I have both of them as a raster object.
>>
>> Similar to the vignette hiking example, I want to compute the  
>> fastest way to get from A to B. Imagine that the object that moves  
>> from A to B is a sailing boat that wants to exploit the best  
>> possible combiantion of winds along all possible paths from A to B.
>>
>> The data structure for now is as follows:
>>
>> vertical <- raster(nrows=10, ncols=10)
>> vertical <- setValues(vertical, runif(10*10, min=-1, max=1) )
>> horizontal <- raster(nrows=10, ncols=10)
>> horizontal <- setValues(horizontal, runif(10*10, min=-1, max=1) )
>>
>> In the hiking example, the direction was either going up or going  
>> down which was captured by the sign of the height difference (i.e.  
>> the slope).
>>
>> They key difference here is, that I essentially have "two signs"  
>> for both speed direction components.
>>
>>
>> I am not sure whether this is possible using the gdistance package;  
>> I would be happy to hear your thoughts and comments.
>>
>> Best,
>> Thiemo
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list