# [R] distance by sea

Yvan Richard yvan at dragonfly.co.nz
Sun Jun 8 08:23:53 CEST 2014

```Tell me if I'm wrong, but I am guessing that you are trying to
calculate the minimum distance between two points, given the presence
of barriers between them. For this problem, I have been using cost
distances.  By giving a raster representing the cost of crossing one
cell of the landscape, the minimum distance that minimises the cost of
movement between two locations can be found.  If you assign the cells
of a projected raster that represent the sea with a value of 1, and
the cells that represent land with a very high value (or infinite),
the resulting cost distance will be the minimum distance over sea,
without going over land.

I have been using GRASS for this, but cost distances can also be
calculated in R with the gdistance package. But I don't have much
experience with it.

Cheers,
-Yvan

On 8 June 2014 18:00, jwd <jwd at surewest.net> wrote:
> On Thu, 5 Jun 2014 14:58:11 +0200
> Giulia Fassio <giuliafassio at gmail.com> wrote:
>
>> Hello,
>>
>> someone know if it is possible to use R to calculate distance by sea
>> between two geographic coordinates? I have many points in the sea and
>> I want to create a matrix using R of the length of trajectories that
>> pass only trough sea.
>>
>> Thanks
>>
>> Giulia
>>
>
> You need to be a great deal more detailed before you are likely to get
> useful advice.  Are you trying to track a sea mammal for example?  Or
> are you working out the course for a sea vessel to travel?
>
> JWDougehrty
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

--
Yvan Richard

DRAGONFLY Science

Physical address: Level 5, 158 Victoria St, Te Aro, Wellington
Postal address: PO Box 27535, Wellington 6141
New Zealand
Ph: 04.385.9285
web page

```