LineLength returns NAN for almost identical points
BenGraeler opened this issue · comments
while
LineLength(matrix(c(7.6-4e-16, 51.96, 7.6, 51.96), nrow = 2, byrow = TRUE), TRUE, FALSE)
returns 0 as a reasonable value, the following
LineLength(matrix(c(7.6-5e-16, 51.96, 7.6, 51.96), nrow = 2, byrow = TRUE), TRUE, FALSE)
returns NAN, and
LineLength(matrix(c(7.6-1e-17, 51.96, 7.6, 51.96), nrow = 2, byrow = TRUE), TRUE, FALSE)
returns 0 again.
We now see
> LineLength(matrix(c(7.6-5e-16, 51.96, 7.6, 51.96), nrow = 2, byrow = TRUE), TRUE, FALSE)
Error in LineLength(matrix(c(7.6 - 5e-16, 51.96, 7.6, 51.96), nrow = 2, :
non-finite line lengths
alternatively, with sf:
> library(sf)
Linking to GEOS 3.6.2, GDAL 2.2.3, proj.4 4.9.3
> st_linestring(matrix(c(7.6-5e-16, 51.96, 7.6, 51.96), nrow = 2, byrow = TRUE))
LINESTRING (7.6 51.96, 7.6 51.96)
> st_length(st_sfc(st_linestring(matrix(c(7.6-5e-16, 51.96, 7.6, 51.96), nrow = 2, byrow = TRUE)), crs = 4326))
0 m