Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LineLength returns NAN for almost identical points #44

Open
BenGraeler opened this issue Dec 21, 2017 · 1 comment
Open

LineLength returns NAN for almost identical points #44

BenGraeler opened this issue Dec 21, 2017 · 1 comment

Comments

@BenGraeler
Copy link
Contributor

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.

@edzer
Copy link
Owner

edzer commented Jun 23, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants