[R-sig-Geo] Distances from points to coast do not make sense.

Robert J. Hijmans r.hijmans at gmail.com
Fri Sep 12 02:25:18 CEST 2014


The below seems to work correctly (albeit slowly).


library(maptools)
library(raster)
library(geosphere)

data(wrld_simpl)
w <- aggregate(wrld_simpl)
af = cbind(16, 13)
ng <- cbind(139, -4)
p <- rbind(af, ng)
dist2Line(p, w)


On Thu, Sep 11, 2014 at 4:13 PM, Agus Camacho <agus.camacho at gmail.com> wrote:
> I have two species, one is widespread in Africa (varanus niloticus) and the
> other is distributed across a region of new Guinea (Varanus prasinus). I
> calculated the mean distance to coast of their respective geographic
> records using the following script:
>
> x1 is a dataframe with two columns: Longitude and Latitude of geographic
> records
>
> meandist=rep(0,length(levels(x$Species)))
> distance=rep(NA,dim(x1)[1])
>
> for(n in 1:dim(x1)[1])
> {
>  distance[n]=(dist2Line(cbind(x1[n,1],x1[n,2]),LAcl,distfun=distVincentyEllipsoid)/1000)[1]
> }
> meandist=mean(distance)
>
> The problem is that geographic records from the african species is giving
> me shorter distances to the coast (mean=6677) than the species from new
> guinea(mean=12417). I already plotted the species records and checked there
> are not bizarre records. I can send the records for anyone insterested.
>
> Thanks in advance.
> Agus
>
>
>
> --
> Agustín Camacho Guerrero.
> Doutor em Zoologia.
> Laboratório de Herpetologia, Departamento de Zoologia, Instituto de
> Biociências, USP.
> Rua do Matão, trav. 14, nº 321, Cidade Universitária,
> São Paulo - SP, CEP: 05508-090, Brasil.
>
>         [[alternative HTML version deleted]]
>
>
> _______________________________________________
> 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