OK so considering these two cases:
ln1<-SpatialLinesDataFrame(SpatialLines(list(Lines(Line(matrix(c(53.3604464,53.36062,-6.2424442, -6.242413),ncol=2)),ID="a"))),data=data.frame(dummy="a"),match.ID=F)
proj4string(pt1) <- CRS("+init=epsg:4326")
SpatialLinesLengths(ln1,longlat=T)*1000
SpatialLinesLengths(spTransform(ln1, CRS("+init=epsg:3857")),longlat=F)
ln2<-SpatialLinesDataFrame(SpatialLines(list(Lines(Line(matrix(c(15.43911,15.43914,47.00849, 47.00837),ncol=2)),ID="a"))),data=data.frame(dummy="a"),match.ID=F)
proj4string(ln2) <- CRS("+init=epsg:4326")
SpatialLinesLengths(ln2,longlat=T)*1000
SpatialLinesLengths(spTransform(ln2, CRS("+init=epsg:3857")),longlat=F)
I calculate the lengths of the lines (ln1 and ln2
) in meters.
The first calculation being the "great circle distance" the second Euclidean distance. Well I read that those distances should lie pretty close to each other when calculated for small distances. That is true for the first case:
Great Circle:
SpatialLinesLengths(ln1,longlat=T)*1000
[1] 19.51758
Euclidean
SpatialLinesLengths(spTransform(ln1, CRS("+init=epsg:3857")),longlat=F)
[1] 19.63836
But in the second case the length difference is pretty great. I mean its over 40%...
Great Circle:
SpatialLinesLengths(ln2,longlat=T)*1000
[1] 13.52404
Euclidean
SpatialLinesLengths(spTransform(ln2, CRS("+init=epsg:3857")),longlat=F)
[1] 19.87276
Well I understand the difference between both methods (straight line vs. "as the crow flies" etc.) but reading (and understanding so) that the difference on small scale should not be to big. I worry seeing something like that...
Is it just because of the distance to the Equator? (What I can't imagine)
Is it a rounding issue?
Is my code wrong? (Well the same effect takes place using gLength(rgeos)
or spDists/spDistsN1(sp)
or any other distance calculation out there for R)
So what's going on here?