Overview

Your webpage must contain the date that you created the document, and it must contain a map created with Leaflet. We would love to see you show off your creativity!

Intractive map for county area

library(leaflet)
## Warning: package 'leaflet' was built under R version 3.5.2
library(sf)
## Warning: package 'sf' was built under R version 3.5.2
## Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3
#https://en.wikipedia.org/wiki/List_of_United_States_counties_and_county_equivalents
#http://eric.clst.org/tech/usgeojson/
setwd("C:/Users/sanjayx/Desktop/coursera/olive_data")
url <- "http://eric.clst.org/assets/wiki/uploads/Stuff/gz_2010_us_050_00_500k.json"
res <- st_read(dsn = url)
## Reading layer `gz_2010_us_050_00_500k' from data source `http://eric.clst.org/assets/wiki/uploads/Stuff/gz_2010_us_050_00_500k.json' using driver `GeoJSON'
## Simple feature collection with 3221 features and 6 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: -179.1473 ymin: 17.88481 xmax: 179.7785 ymax: 71.35256
## epsg (SRID):    4326
## proj4string:    +proj=longlat +datum=WGS84 +no_defs
# Set the view of Reston
bins <- c(10,100,500, 1000, 10000, 20000, Inf)
pal <- colorBin("YlOrRd", domain = res$CENSUSAREA, bins = bins)
res  %>% leaflet() %>%
  addTiles() %>% # Add default OpenStreetMap map tiles
  setView(lng = -77, lat = 38, zoom =3) %>% 
  addPolygons(
  fillColor = ~pal(CENSUSAREA),
  weight = 2,
  opacity = 1,
  color = "white",
  dashArray = "3",
  fillOpacity = 0.7)
## Warning in pal(CENSUSAREA): Some values were outside the color scale and
## will be treated as NA
  #addGeoJSON(counties) # Add geo json