Skip to content

Lines between nearest neighbours (from st_connect) are not shown on map #483

Open
@marekie

Description

@marekie

Using the data from a question on SO, I cannot reproduce the outcome in this answer as the lines between the points are not plotted. I am running R version 4.4.0 Patched (2024-05-26 r86634 ucrt) and mapview_2.11.2.9000.

person_location <-
structure(list(id = c(1, 2, 3, 4, 5), longitude = c(-76.67707, 
-76.44519, -76.69402, -76.68936, -76.58341), latitude = c(39.399754, 
39.285084, 39.36958, 39.369907, 39.357994)), class = "data.frame", row.names = c(NA, 
-5L))

building_location <-
structure(list(id = c(1, 2, 3, 4, 5, 6, 7, 8, 9), longitude = c(-76.624393, 
-76.457246, -76.711729, -76.631249, -76.566742, -76.683106, -76.530232, 
-76.598582, -76.691287), latitude = c(39.246464, 39.336996, 39.242936, 
39.289103, 39.286271, 39.35447, 39.332398, 39.344642, 39.292849
)), class = "data.frame", row.names = c(NA, -9L))

person_location <- person_location %>%
  st_as_sf(coords = c('longitude', 'latitude')) %>%
  st_set_crs(4326)

building_location <- building_location %>%
  st_as_sf(coords = c('longitude', 'latitude')) %>%
  st_set_crs(4326)

st_connect(person_location, building_location) %>% 
  mapview::mapview() +
  mapview::mapview(person_location, color = 'green', col.regions = 'green') + 
  mapview::mapview(building_location, color = 'black', col.regions = 'black')

2024-05-28 11_07_44-Window

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