Skip to content

Instantly share code, notes, and snippets.

@jatorre
Created February 8, 2012 20:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jatorre/1773190 to your computer and use it in GitHub Desktop.
Save jatorre/1773190 to your computer and use it in GitHub Desktop.
#wifi {
[type='Free'] {marker-fill:black}
[type!='Free'] {marker-fill:red}
marker-width:5;
marker-line-color:white;
}
--------------------------------------------------
SELECT * FROM wifi WHERE type='Free' AND zip='10010'
--------------------------------------------------
SELECT * FROM wifi ORDER BY the_geom <-> ST_GeomFromText('POINT(-73.989418 40.7393)',4326) limit 100
http://viz2.cartodb.com/api/v1/sql?q=
SELECT cartodb_id,ST_distance(ST_GeomFromText('POINT(-73.989418 40.7393)',4326)::geography,the_geom::geography) as distance_to_office,st_x(the_geom) as lon,st_y(the_geom) as lat FROM wifi ORDER BY distance_to_office ASC LIMIT 10
--------------------------------------------------
SELECT * FROM parks as p WHERE (SELECT count(*) FROM wifi as w WHERE ST_Intersects(w.the_geom,p.the_geom))>0
--------------------------------------------------
#parks{
polygon-fill:#FFF;
line-width:1;
polygon-opacity:1;
line-opacity:0.2;
polygon-pattern-file:url(/home/ubuntu/tile_assets/patt1.png);
text-name:"[signname]";
text-face-name:"DejaVu Sans Book";
text-size:12;
text-halo-radius:1;
text-fill:#333;
text-halo-fill:rgba(255,255,255,1);
text-wrap-width: 100;
text-allow-overlap:false;
text-placement-type:simple;
text-avoid-edges:true;
}
BONUS:
UPDATE nyct2000 as f SET num_stop_frisk=(SELECT count(*) from stop_frisk as w WHERE ST_Intersects(f.the_geom,w.the_geom))/ST_Area(the_geom)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment