Yesterday, a student at the Southern University of the city planning on Sina Weibo @ I,
By that he means to convert the JSON data to vector graphics, I didn't hear a good switch before, and I saw that Chicago really put the city planning data on the GitHub, see here: http://thechangelog.com/ the-city-of-chicago-is-on-github/
Choose one of them at random, I choose bike here.
Routes in Chicago, you can see the items above GitHub, including data and examples. In the readme.md surprised discovery can also use the R language to draw, just want to learn r language, so a small try. It is worth mentioning that the author has written in detail the steps in the document, follow the steps step by step.
# title:importing Geojson Example in R # Author:tom Schenk Jr., City of Chicago # created:2013-01-23 # updated:2013-01 -31 # NOTES: # Libraries:rgdal, Ggplot2 # Set working directory (e.g., "c:\\users\\username\\downloads" or "~/downloads" ) SETWD ("Path\\to\\folder") # Install and load Libraries # # IF You are need to Install the Rgdal and GGPLOT2, libraries Ete This step, otherwise, skip:install.packages (C ("Rgdal", "Ggplot2")) library (rgdal) # Import data into a Spatial Data frame in R library (GGPLOT2) # Transform data ' Shapefile to ' data frame # Import data to Spatial dataframe Ogrin Fo ("Data\\bikeroutes.json", layer= "Ogrgeojson") bikeroutes.shapefile <-readogr (dsn= "Data\\bikeroutes.json", Layer= "Ogrgeojson", p4s= "+proj=tmerc +ellps=wgs84") # Imports data. Replace path\\to with actual file PATH (e.g., c:\\users\\username\\downloads) head (bikeroutes.shapefile) # Inspect the DA
TA structure.
Plot (bikeroutes.shapefile) # Test plot of spatial data frame. # fortify Data to translate to data Frame bikeroutes.df <-fortify (bikeroutes.shapefile) # Caution, this is very memory Intensiv E and may take several hours to complete head (BIKEROUTES.DF) # Inspect The data structure Ggplot (BIKEROUTES.DF, AES (X=lo Ng, Y=lat, Group=group)) + Geom_path () # Test plot of data frame.
Data in the GitHub project in the database folder, CSV data download can be, the resulting results are as follows: