Class 4
2 pages
work plan:
data (where's it coming from? what will you have to do to it?)
work plan:
what will it look like? include a sketch.
work plan:
what do you need to learn to make this happen?
this will likely change as you do your project, and that's okay
define a milestone for yourself. it will be due 4/9.
#earthquakes {
marker-fill: #ff307a;
marker-line-color: #FFF;
marker-line-width: 0.25;
marker-line-opacity: 0.4;
marker-width: 2;
marker-allow-overlap: true;
}
#earthquakes {
marker-width: 3;
...
[mag >= 6.5] {
marker-width: 8;
}
}
#earthquakes {
marker-width: 3;
...
[zoom >= 10][zoom < 16] {
marker-width: 8;
}
}
#earthquakes {
marker-width: 3;
...
[mag > 5.5],
[place = 'Northern Mid-Atlantic Ridge'] {
marker-width: 8;
}
}
@width: 8;
#earthquakes {
marker-width: @width;
marker-fill: #ff307a;
marker-allow-overlap: true;
[zoom >= 4] {
marker-width: @width * 2;
}
[zoom >= 8] {
marker-width: @width * 3;
}
[zoom >= 12] {
marker-width: @width * 4;
}
}
Class 4
you need HTML and CSS. we'll get there.
Give me the pages that refer to properties in Brooklyn.
Give me the addresses of the properties in Brooklyn.
just list the columns. for example:
SELECT mag, place FROM earthquakes
for example:
SELECT * FROM earthquakes WHERE mag > 6 AND mag < 7
get just the earthquakes with mag between 7 and 7.5
these conditions are the same as the ones in CartoCSS:
> < = != >= <=
for example:
SELECT * FROM earthquakes WHERE mag > 6 AND place = 'Northern Mid-Atlantic Ridge'
for example:
SELECT * FROM earthquakes WHERE mag > 6 OR place = 'Northern Mid-Atlantic Ridge'
for example:
SELECT * FROM earthquakes WHERE NOT (mag > 6 OR place = 'Northern Mid-Atlantic Ridge')
for example:
SELECT * FROM earthquakes WHERE NOT (mag > 6 OR place = 'Northern Mid-Atlantic Ridge')
(match any rows that do not match the condition)
get just the earthquakes with mag not between 7 and 7.5
get a count of matching rows:
SELECT COUNT(*) FROM earthquakes WHERE mag > 6 OR place = 'Northern Mid-Atlantic Ridge'
get the number of earthquakes with mag between 7 and 7.5
UPDATE earthquakes SET mag_display = 'HUGE' WHERE mag > 8
DELETE FROM earthquakes WHERE ...
more in the SQL cheatsheet in Lore
http://eric.cartodb.com/api/v2/
sql?q=SELECT COUNT(*)
FROM earthquakes
WHERE mag > 7
view results
http://eric.cartodb.com/api/v2/sql?q=SELECT COUNT(*) FROM earthquakes WHERE mag > 7
http://eric.cartodb.com/api/v2/
sql?q=SELECT *
FROM earthquakes
WHERE mag > 7
view results
http://{your username}.cartodb.com
/api/v2/sql?q={your query}
how to write a shapefile:
{
...
}
{
"type": "FeatureCollection",
"features": [ ... ]
}
{
"type": "FeatureCollection",
"features": [
{ ... },
{ ... },
{ ... }
]
}
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"id": 1,
"Name": "My House",
"City": "White Hall",
"Comments": "It's OK"
},
"geometry": {
"type": "Point",
"coordinates": [-76.596, 39.684]
}
}
]
}
http://eric.cartodb.com/api/v2/
sql?q=SELECT *
FROM earthquakes
WHERE mag > 7
http://eric.cartodb.com/api/v2/
sql?q=SELECT *
FROM earthquakes
WHERE mag > 7
&format=geojson
view results
or through github