Skip to content

LineLength returns NAN for almost identical points #44

Open

Description

@BenGraeler

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.

Activity

  1. edzer commented on Jun 23, 2018

    @edzer
    Owner

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions