traffic api ppt

10
DATA COLLECTION- TRAFFIC API

Upload: abhinav-rastogi

Post on 07-Jan-2017

80 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: TRAFFIC API PPT

DATA COLLECTION-TRAFFIC API

Page 2: TRAFFIC API PPT

GROUP MEMBERS Abhinav - 71520071 Shanmukh - 71520022 Swarna - 71520112 Vinisha - 71520104

Page 3: TRAFFIC API PPT

API details Map quest Free traffic API Location : Chicago , IL Boundary : Latitude : 42.023135, -87.940 Longitude: 41.644286, -87.523661

Page 4: TRAFFIC API PPT

URL BUILT *: http://www.mapquestapi.com/traffic/v2/

incidents?key=9MeX47CdULA7fqTMbUmphHwGZQlezisk&boundingBox=42.023135, -87.940101,41.644286, -87.523661&filters=construction,incidents&inFormat=kvp&outFormat=json

*Incidents Data

Page 5: TRAFFIC API PPT

Codelibrary("RCurl")library("jsonlite")library("data.table")

url = paste0("http://www.mapquestapi.com/traffic/v2/incidents?key=9MeX47CdULA7fqTMbUmphHwGZQlezisk&boundingBox=42.023135,%20-87.940101,41.644286,%20-87.523661&filters=construction,incidents&inFormat=kvp&outFormat=json")doc <- getURL(url)x <- jsonlite::fromJSON(doc)

ids = x$incidents$idtype = x$incidents$typeseverity = x$incidents$severitylongitude = x$incidents$lnglatitude = x$incidents$latstartTime = x$incidents$startTimeendTime = x$incidents$endTimeshortDesc = x$incidents$shortDescfullDesc = x$incidents$fullDescdelayFromFreeFlow = x$incidents$delayFromFreeFlowdelayFromTypical = x$incidents$delayFromTypicaldistance = x$incidents$distanceroadName = x$incidents$parameterizedDescription$roadNamedirection = x$incidents$parameterizedDescription$directioneventText = x$incidents$parameterizedDescription$eventTexttoLocation = x$incidents$parameterizedDescription$toLocatioiconURL = x$incidents$iconURL

b=data.table(ids,type,severity,longitude,startTime,endTime,shortDesc,fullDesc,delayFromFreeFlow,delayFromTypical,distance,roadName,direction,eventText,toLocation,iconURL,keep.rownames=True)dim(b)write.csv(b,"OutputTable_Assignment3.csv", row.names = T)

Page 6: TRAFFIC API PPT

TOOLS USED- MS EXCEL- R Studio

Page 7: TRAFFIC API PPT

OUTPUT

Page 8: TRAFFIC API PPT

R Code & Output File

TrafficAPI.R

Microsoft Excel Comma Separated Values Fi

Page 9: TRAFFIC API PPT

LEARNINGS WHILE USING APIs

SSL shows local verifier Error if Https is used (resolved by doc <- getURL(url, .opts = list(ssl.verifypeer = FALSE)) )

If cross domain data is extracted then Callback is to be handled

JSON data transformation will allow to extract all data as list while merging in data frames individual rows were binded so used data tables.

Page 10: TRAFFIC API PPT

Thanks