r - Creating US Map Including State Borders in ggvis -
I am trying to make an American map after which I can add interactive layers. Depending on the polygon, however, an order seems to be an issue; I have ordered them in different ways, and none of them was working properly. Any help would be appreciated.
Library (ggplot2) library (ggvis) library (dplyr) mdat & lt; -map_data ("state") mdat% & gt;% system (group, order)% & gt;% Ggvis (x = ~ long, y = ~ lat)% & gt;% layer_path ()Library (ggplot2) Library (Ggvis) library (dplyr) library library (httr) # decent American shape file and adapter only D / L Features Defense gives when stop_for_status (GET ( "http://eric.clst.org/wupl/Stuff/gz_2010_us_040_00_500k Json", write_disk ( "us.geojson"), (Progress))) states & lt; - readOGR ("us.geojson", "OGRGeoJSON") states & lt; - states [! States, CRS ("+ proj = laea + lat_0 = 45 + lon_0 = -100 + x_0 = 0 + y_0 =" + "=" 0 + a = 6370997 + b = 6370997 + unit S = m + no_defs ") states_map & Lt; - fortify (states_aea, region = "NAME") states_map% & gt;% group_by (group)% & gt;% ggvis (~ long, ~ lat)% & gt;% layer_paths (stroke opacity): = 0.5 , Stroke width: = 0.5)%>% hide_axis ("x")%>% hide_exe ("y")%>% set_options (width = 960, height = 600, keep_aspect = TRUE)
![]()
Comments
Post a Comment