Plotting sfc_POLYGON in leaflet

Viewed 3135

I have a sfc_POLYGON, IHS obtained as a union of a few shapes using the sf package.

Geometry set for 1 feature 
geometry type:  POLYGON
dimension:      XY
bbox:           xmin: 270194.7 ymin: 2255850 xmax: 279225 ymax: 2265469
epsg (SRID):    32643
proj4string:    +proj=utm +zone=43 +datum=WGS84 +units=m +no_defs
POLYGON((279224.998943279 2261084.1514869, 2792...

While I am able to plot this in mapview, I am facing some problems while plotting the same in leaflet. When I plot this is leaflet, I get a warning sf layer is not long-lat data which it isn't, and I get the base world map. This is the code I used for plotting in leaflet.

IHS%>%leaflet()%>%addTiles()%>%
  addProviderTiles(providers$Esri.WorldImagery, group ="ESRI")%>%
  addPolygons()

I suspect this has to do something with the CRS. I have tried st_set_crs(IHS, 4326)which changes my projection of IHS from utm to longlat:

Geometry set for 1 feature 
geometry type:  POLYGON
dimension:      XY
bbox:           xmin: 270194.7 ymin: 2255850 xmax: 279225 ymax: 2265469
epsg (SRID):    4326
proj4string:    +proj=longlat +datum=WGS84 +no_defs

However there is no change in the leaflet warning and output. I am not sure here, but has it got something to do with changing the dimension and bbox (which appears to be in meters)?

1 Answers
Related