0

I'm trying to reproduce a code to display polygons in a map in another computer, however, in one computer the polygons are not shown. Does someone had this kind of problem while sharing code? You can download the shapefile from here: http://www.conabio.gob.mx/informacion/metadata/gis/muni_2012gw.xml?_xsl=/db/metadata/xsl/fgdc_html.xsl&_indent=no

library(rgdal)
library(rgeos)
library(leaflet)

Mex <- readOGR(dsn="C:/DISCO D", layer="Muni_2012gw")
Mex_sub <- Mex[Mex$CVE_ENT=="01",]



bins <- quantile(Mex_sub@data$OID_1, c(0,.125,.25, .5, .75,.875, 1))
pal <- colorBin("YlOrRd", domain = Mex_sub@data$OID_1, bins = (bins),
                na.color = "grey40", reverse = FALSE)

centr <- gCentroid(Mex_sub)@coords
leaflet(Mex_sub, options = leafletOptions(minZoom = 4, maxZoom = 15)) %>% 
  addTiles() %>%
  setView(centr[1], centr[2], zoom = 8) %>%
  addPolygons(data=Mex_sub, weight = 1,fill = ~OID_1, fillColor = ~pal(OID_1),
              opacity=1, fillOpacity = 0.5, color=grey(0.5))

Map in my computer

Map in the other computer

MLavoie
  • 9,671
  • 41
  • 36
  • 56
Heber Trujillo
  • 123
  • 1
  • 5
  • You should provide a reproducible example to see if we can reproduce the problem. – MLavoie May 07 '18 at 20:29
  • Thanks for your help, I've edited the previous post to provide a reproducible example. – Heber Trujillo May 08 '18 at 18:28
  • I cannot reproduce the error. I see all the polygons. We would need more information to explain why it does not work on the other computer. Does it have the same R and packages versions? – MLavoie May 08 '18 at 18:43
  • Seems that the most recent version of leaflet and rgdal were the problem. It's working now on both computers. – Heber Trujillo May 08 '18 at 19:06

0 Answers0