Leaflet R derivePolygons missing lat missing long

前端 未结 2 1859
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:14

    The addPolygons function either requires you to define the columns of latitude & longitude, OR it will try and derive them from the data you provide.

    Given you haven't specified the lat/lon columns, it tries to work out which ones they are. In your case, it couldn't find them. This is mainly due to your data not being in lat/lon format.

    Therefore, you'll need to transform your data to use a lat/lon projection, something like (untested)

    nByTown_latlon <- spTransform(nByTown, CRS("+proj=longlat +datum=WGS84"))
    

提交回复
热议问题