Skip to content

Instantly share code, notes, and snippets.

@jeroenjanssens
Last active August 29, 2015 14:07
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeroenjanssens/19389159c1331de0d459 to your computer and use it in GitHub Desktop.
Save jeroenjanssens/19389159c1331de0d459 to your computer and use it in GitHub Desktop.
Data Science at the Command Line Strata Tutorial
# make sure that you have the R package `ggmap` installed
curl -s http://api.citybik.es/citi-bike-nyc.json > citibikes.json
< citibikes.json jq -r '.[] | [.lat/1000000,.lng/1000000,.bikes] | @csv' | header -a lat,lng,bikes > citibikes.csv
< citibikes.csv Rio -vge 'require(ggmap); qmap("NYC", zoom=14) + geom_point(data=df, aes(x=lng, y=lat, size=bikes))' > citibikes.png
$ curl -sL 'http://en.wikipedia.org/wiki/List_of_countries_and_territories_by_border/area_ratio' | scrape -be 'table.wikitable > tr:not(:first-child)' | xml2json | jq -c '.html.body.tr[] | {country: .td[1][], border: .td[2][], surface: .td[3][], ratio: .td[4][]}' | json2csv -p -k=border,surface | head -n 11 | csvlook
@catch93
Copy link

catch93 commented Oct 15, 2014

I am having issues tryijng to display the map on localhost:8000.. getting a message says image can not be displayed due to errors
Here are the steps that I did

  1. curl -s http://api.citybik.es/citi-bike-nyc.json > citibikes.json
  2. < citibikes.json jq -r '.[] | [.lat/1000000, .lng/1000000,.bikes]|@csv' > citibikes.csv
  3. < citibikes.csv header -a lat,lng,bikes > citibikes.header.csv
  4. R -- create bikes df from read.csv(citibikes.csv.headers)
  5. < citibikes.header.csv Rio -ge 'require(ggmap); qmap(“NYC”, zoom=14) + geom_point(dated=df, aes(x=lng, y=lat, size=bikes))' > citibikes.png

initiated a SimpleHTTPServer

python -m SimpleHTTPServer &

Hope you can assist in letting me know what step I miss

@jeroenjanssens
Copy link
Author

I think you misspelled data in the Rio expression. Please see the updated commands in case-citibikes.sh and let me know if that works. (If you get an error in Rio, you can also specify the -v option to see the error.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment