Geojson artifacts displaying in Shiny


After importing a lines shapefile (link below) and converting to geojson, the file is being displayed with shaded artifacts. Adding the SpatialLines DataFrame (created with readOGR) with addPolylines works fine, but is slow to display. I’ve also tried to reduce file size of the shapefile but would prefer to use geojson as it loads more quickly. The artifacts are not evident after writing to a geojson output file (geojson_write) and displaying in QGIS, so I guess this may be related to rendering in Shiny, or something I’ve missed?

Method adding large json file to Shiny:
roads_vn <- readOGR(dsn = “./geospatial_files/osm/roads_rmapshaper”, layer = “osm_roads_motorways_trunk_primary”)
roads_vnjs <- geojson_json(roads_vn)

observeEvent(input$roads_vn, {
ib <- input$roads_vn
proxy <- leafletProxy(“map”)
if(ib != 0){proxy %>% addGeoJSON(geojson = roads_vnjs, weight = 2, group = “roadv”, color = “#ff6700”)}
else {proxy %>% clearGroup(“roadv”)}



What happens if you load the geojson output file you tried with QGIS?

geojson <- readLines("path-to-json-file") %>% paste(collapse = "\n")
... snip ...
  addGeoJSON(geojson = geojson, ...)