How to create polygons around states in leaflet?

0 votes
How to create polygons around states in leaflet?
Sep 24 in Data Analytics by anonymous
• 3,290 points
15 views

1 answer to this question.

0 votes

Use addPolygons() to create polygons in a leaflet. See the below example to create polygons.

neStates <- subset(states, states$STUSPS %in% c(
  "CT","ME","MA","NH","RI","VT","NY","NJ","PA"
))

leaflet(neStates) %>%
  addPolygons(color = "#444444", weight = 1, smoothFactor = 0.5,
    opacity = 1.0, fillOpacity = 0.5,
    fillColor = ~colorQuantile("YlOrRd", ALAND)(ALAND),
    highlightOptions = highlightOptions(color = "white", weight = 2,
      bringToFront = TRUE))

See the below manual to create polygons in leaflet.

https://rstudio.github.io/leaflet/shapes.html

answered Oct 28 by Cherukuri
• 32,260 points

Related Questions In Data Analytics

0 votes
1 answer

How to create clusers in leaflet?

Hey! Try using marker cluster. See this post, its ...READ MORE

answered Sep 23 in Data Analytics by anonymous
• 3,290 points
21 views
0 votes
1 answer

How to create icons for markers in leaflet?

Hi @ch, Create an icon use makeicon function ...READ MORE

answered Sep 23 in Data Analytics by anonymous
• 3,290 points
25 views
0 votes
1 answer

How to create excellent examples in R?

An excellent example must consist of the ...READ MORE

answered Apr 10, 2018 in Data Analytics by kappa3010
• 2,070 points

edited Apr 12, 2018 by kappa3010 43 views
0 votes
1 answer

How to create dummy variables based on a categorical variable of lists in R?

You can use mtabulate in the following way: library(qdapTools) cbind(data[1], ...READ MORE

answered Apr 13, 2018 in Data Analytics by CodingByHeart77
• 3,690 points
617 views
0 votes
1 answer

plot map points from a dataframe

Hi Peter, Use below code. leaflet(df) %>% addTiles() %>% ...READ MORE

answered Sep 17 in Data Analytics by priya
26 views
0 votes
1 answer

How to add external markers in maps?

Use external markers by creating icons using ...READ MORE

answered Oct 14 in Data Analytics by Cherukuri
• 32,260 points
23 views
0 votes
1 answer

How to add legend or any text on the map in leaflet?

See below example, > p = colorFactor(palette = ...READ MORE

answered Oct 28 in Data Analytics by anonymous
• 32,260 points
68 views
0 votes
0 answers

fix the map area using leaflet and use ggplot

I created a map using leaflet and ...READ MORE

Sep 18 in Data Analytics by anonymous
• 32,260 points
19 views
0 votes
2 answers

How to create a table in R without external file?

Tibble also creates a table-like structure. Use below ...READ MORE

answered Sep 3 in Data Analytics by anonymous
• 32,260 points
76 views
0 votes
1 answer

How to create a Heatmap in R?

Its very simple. Use heatmap function and ...READ MORE

answered Nov 3 in Data Analytics by Cherukuri
• 32,260 points
37 views