Leaflet R derivePolygons missing lat missing long

前端 未结 2 1884
Happy的楠姐
Happy的楠姐 2021-01-13 04:28

I am trying to plot the site of some disease-events data on a map.

I use this to import the data:

ByTown<-readOGR(dsn=\"C:/temp/lyme/Towns\", lay         


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-13 05:08

    Don't forget to add the data = ... variable name in addPolygons() if you don't provide it in the leaflet() call. I received the same error and spent hours looking for a solution :(.

    This does not work:

    leaflet() %>%
      addTiles() %>%
      addPolygons(ByTown)
    

    and returns:

    Error in derivePolygons(data, lng, lat, missing(lng), missing(lat), "addPolygons") : 
      addPolygons must be called with both lng and lat, or with neither.
    

    This works:

    leaflet() %>%
      addTiles() %>%
      addPolygons(data = ByTown)
    

提交回复
热议问题