[R] Static to interactive map (leaflet spplot)
Adams, Jean
jvadams at usgs.gov
Wed Feb 17 14:02:59 CET 2016
Deb,
I assume you have already seen the great introduction to leaflet here ...
http://rstudio.github.io/leaflet/
You may find these two answers on stackoverflow helpful ...
http://stackoverflow.com/a/28240058/2140956
http://stackoverflow.com/a/29118680/2140956
Jean
On Tue, Feb 2, 2016 at 5:28 PM, Debasish Pai Mazumder <pai1981 at gmail.com>
wrote:
> Hi ALL,
>
> I have a script to plot hexagonal polygon on a map. Its a static map. I
> used spplot. I would like to convert this plot to interactive plot using "
> *leaflet*". How do I make it interactive plot?
>
> Here is spplot lines:
>
> cl = map("world", xlim = c(-120, 20), ylim = c(-10, 70), plot = TRUE)
> cl = map("world",plot = TRUE)
> clp = map2SpatialLines(cl, proj4string = CRS(ll))
> clp = spTransform(clp, CRS(lcc))
> l2 = list("sp.lines", clp, col = "black", lty = 1, lwd = 3)
>
> cr = colorRampPalette(brewer.pal(9,"YlOrRd"))(100)
>
> require(grid)
> spplot(hspdf, "CDP", col = "white", col.regions = cr,
> sp.layout = list(l2),
> at = seq(0,100,10),
> sub = list("CDP", cex = 1.5, font = 2))
>
> where
> > hspdf
> class : SpatialPolygonsDataFrame
> features : 95
> extent : -4141330, 3748528, 1530846, 6914278 (xmin, xmax, ymin, ymax)
> coord. ref. : +proj=lcc +lat_1=60 +lat_2=30 +lon_0=-60 +ellps=WGS84
> variables : 4
> names : hexid, count, hct, CDP
> min values : 37, 1, 1, 0.136612021857923
> max values : 448, 7, 3, 39.4391854927413
>
> CDP values of each hexagonal polygon.
>
> -Deb
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list