Skip to content

Instantly share code, notes, and snippets.

@andy-esch
Last active August 29, 2015 14:16
Show Gist options
  • Save andy-esch/6f2d56745b9fa7d535eb to your computer and use it in GitHub Desktop.
Save andy-esch/6f2d56745b9fa7d535eb to your computer and use it in GitHub Desktop.
Cornell Data Science Hackathon

Cornell Data Science Hackathon

Andy Eschbacher, Map Scientist, CartoDB

@MrEPhysics | [email protected]

What is CartoDB?

  • Cloud-based spatial analytics platform. i.e., Data Visualizations + Maps
  • Not just mapping platform -- flexible database (PostgreSQL) in the cloud

We have APIs

  1. CartoDB.js -- JavaScript API
  2. Torque.js -- Temporal mappping JS API
  3. SQL API -- Data API
  4. Maps API -- Public maps/private data, static maps (export as images), etc.
  5. Import API -- Push files to your account

Quick tour of the Editor

Data import

Most major formats supported: CSV, GeoJSON, KML, etc.

SQL Interface

Run SQL http://docs.cartodb.com/cartodb-editor.html#custom-sql

CartoCSS -- Map Stylings

http://docs.cartodb.com/cartodb-editor.html#cartocss http://docs.cartodb.com/img/layout/cartodb-editor/cartocss.68c60b68.png

Analytics within a database

Mathematical/statistical operations in data tables: http://www.postgresql.org/docs/9.3/static/functions-aggregate.html

  • Mean, median, mode, etc.
  • Std dev, regression, covariance

String processing: http://www.postgresql.org/docs/9.3/static/functions-string.html

Pattern Matching/RegEx: http://www.postgresql.org/docs/9.3/static/functions-matching.html

Format juggling:

Tons more: http://www.postgresql.org/docs/9.3/static/functions.html

Flexible Data Export using SQL API

Format:

http://{account_name}.cartodb.com/api/v2/sql?q={custom_sql_query}&format={desired_format}&filename={output_file_name}

format: csv, geojson, shp, etc.

R's read.csv() and Panda's pd.read_csv() are not only for local files

Can easily use with Python pandas (pd.read_csv) and R (read.csv). Check out demo on Plotly I made last week: https://plot.ly/ipython-notebooks/cartodb/

Spatio-temporal Analysis

PostGIS -- the geospatial extension to PostgreSQL

SELECT superhero.name
FROM city, superhero
WHERE ST_Contains(city.the_geom, superhero.the_geom)
AND city.name = 'Gotham'

Resources:

Torque (documentation)

Examples:

Accounts

Get (better) free accounts here: https://cartodb.com/signup?plan=academy

If you already have an account and want the student upgrade, email me ([email protected]) and I'll bump you up.

Resources

Need help?? Tweet at me @MrEPhysics

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