On Github auremoser / HCB-mapping
Created by Stuart Lynn + Aurelia Moser + David Bild @stuart_lynn @auremoser @dbild
+
=
Maps are great!
Maps can also be beautiful
At the Hive Chicago meet up.
1647 S Blue Island Ave, Chicago, IL 60608
41.858408, -87.660331
41° 51' 30.2688" N, 87° 39' 37.1916'' W
Reads as 41 hours 51 minutes 30.3 Seconds North, 87 degrees 39 minutes 37 seconds west
https://a.tiles.mapbox.com/v4/mapbox.streets/0/0/0.png
1/0/0
1/1/0
1/0/1
1/1/1
Can be more powerful but can also be more complicated
Pretty straight forward but can be restrictive
Table of points with attributes
lat long population area -20.23 10.443 300 20 0.33 -23.333 55 2303 33.33 -2.333 123 2Table of points with attributes
address population area 180 South Michigan, Chicago, IL 300 20 20 South Clark, Chicago, IL 55 2303 1817 South Allport, Chicago, IL 123 2Geocoders are peices of software that turn adresses in to locations
MapZen's pelias https://mapzen.com/pelias
MapBox geocoder https://www.mapbox.com/developers/api/geocoding/
Google has an excelent geocoder but it can be restrictive
Used a lot by google maps
Usually contains vector data and sometimes image overlays
Vector data format from ESRI
Usually a zip file containing multiple files with endings like .shp .shx .dbf .sbn
Going to need this file: libraries.kml
https://help.github.com/articles/mapping-geojson-files-on-github/
SELECT * FROM buildings where shape_area > 100
/** choropleth visualization */ #buildings{ polygon-fill: #91003F; polygon-opacity: 0.8; line-color: #FFF; line-width: 0; line-opacity: 1; } #buildings [ year_built <= 2013] { polygon-fill: #F1EEF6; } #buildings [ year_built <= 1990] { polygon-fill: #D4B9DA; } #buildings [ year_built <= 1967] { polygon-fill: #C994C7; } #buildings [ year_built <= 1944] { polygon-fill: #DF65B0; } #buildings [ year_built <= 1920] { polygon-fill: #E7298A; } #buildings [ year_built <= 1897] { polygon-fill: #CE1256; } #buildings [ year_built <= 1874] { polygon-fill: #91003F; }
// create a layer with 1 sublayer cartodb.createLayer(map, { user_name: 'mycartodbuser', type: 'cartodb', sublayers: [{ sql: "SELECT * FROM table_name", cartocss: '#table_name {marker-fill: #F0F0F0;}' }] }) .addTo(map) // add the layer to our map which already contains 1 sublayer .done(function(layer) { // create and add a new sublayer layer.createSubLayer({ sql: "SELECT * FROM table_name limit 200", cartocss: '#table_name {marker-fill: #F0F0F0;}' }); // change the query for the first layer layer.getSubLayer(0).setSQL("SELECT * FROM table_name limit 10"); });
var sql = new cartodb.SQL({ user: 'cartodb_user' }); sql.execute("SELECT * FROM table_name WHERE id > {{id}}", { id: 3 }) .done(function(data) { console.log(data.rows); }) .error(function(errors) { // errors contains a list of errors console.log("errors:" + errors); })
gem 'cartodb-rb-client'