How to create polygons around states in leaflet

+1 vote
How to create polygons around states in leaflet?
Sep 25, 2019 in Data Analytics by anonymous
• 3,450 points
1,221 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 29, 2019 by Cherukuri
• 33,030 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, 2019 in Data Analytics by anonymous
• 3,450 points
844 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, 2019 in Data Analytics by anonymous
• 3,450 points
1,006 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,090 points

edited Apr 12, 2018 by kappa3010 760 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,750 points
2,623 views
0 votes
1 answer

plot map points from a dataframe

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

answered Sep 17, 2019 in Data Analytics by priya
921 views
0 votes
1 answer

How to add external markers in maps?

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

answered Oct 14, 2019 in Data Analytics by Cherukuri
• 33,030 points
907 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, 2019 in Data Analytics by anonymous
• 33,030 points
8,910 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, 2019 in Data Analytics by anonymous
• 33,030 points
664 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, 2019 in Data Analytics by anonymous
• 33,030 points
3,017 views
0 votes
1 answer

How to create a Heatmap in R?

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

answered Nov 3, 2019 in Data Analytics by Cherukuri
• 33,030 points
740 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP