Skip to content

Instantly share code, notes, and snippets.

View andrewbt's full-sized avatar

Andrew Thompson andrewbt

View GitHub Profile
@andrewbt
andrewbt / opentreemap_v1.2_release_notes.md
Created October 25, 2012 16:20
OpenTreeMap v1.2 Release Notes

OpenTreeMap Release Notes

Project at http://github.com/azavea/opentreemap

v1.2

API for mobile applications

  • A RESTful API that accepts and returns JSON with endpoints for:
  • Tree searching, filtering.
@andrewbt
andrewbt / index.html
Created March 31, 2015 19:06
Simple CartoDB Torque Map without a time-slider bar
<!DOCTYPE html>
<html>
<head>
<title>Easy example | CartoDB.js</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="shortcut icon" href="http://cartodb.com/assets/favicon.ico" />
<style>
html, body, #map {
height: 100%;
@andrewbt
andrewbt / record_information_outside_map_canvas.html
Last active August 29, 2015 14:18
This is an excerpt from a store-locator app we were building. Information that is often in infowindows on the map canvas is displayed in a "store-info" sidebar <div> outside the map canvas
...
<body>
<div id="map-container">
<input id="pac-input" class="controls" type="text"
placeholder="Enter a location">
<div id="map-canvas"></div>
</div>
<div id="store-info">
<p>Search an address in the box above, which will autocomplete for you. The nearest 5 store locations will be displayed here with selected details about each location.</p>
</div>
@andrewbt
andrewbt / fun_cartodb_sql.sql
Last active September 22, 2022 22:33
CartoDB SQL tricks: Various things that as a SQL-newbie I had to search for >10 minutes to find answers for.
-- union neighboring counties together into one polygon
SELECT 1 as cartodb_id, ST_Union(ST_SnapToGrid(the_geom,0.0001)) as the_geom FROM public.cb_2018_us_county_500k where name in ('Tompkins', 'Tioga', 'Broome') and statefp = '36'
-- want to update one column with multiple values in the same query? And use a function in a CASE?
UPDATE loan_data_copy
SET the_geom = (
CASE
WHEN city = 'Columbus ' THEN ST_GeomFromText('POINT(33.12 -87.12)', 4326)
WHEN city = 'Meridian ' THEN ST_GeomFromText('POINT(33.123 -88.123)', 4326)
WHEN city = 'Tuscaloosa' THEN ST_GeomFromText('POINT(33.321 -88.312)', 4326)
@andrewbt
andrewbt / commercial-data.json
Created June 1, 2015 23:51
Vis with great circle lines and leaflet q-cluster plugin
[{"name":101,"address":"5022 Hartley Peavey Dr","city":"Meridian","state":"MS","zip":39305,"loan_balance":750000,"payoff_date":2017,"interest_rate":null,"consumer_commercial":"Commercial ","type_of_loan":null,"employer":"C","the_geom":"0101000020E6100000F901FEDFC72C56C0BE9B1320AF344040","created_at":"2015-05-29T17:17:26Z","updated_at":"2015-06-01T23:08:04Z","the_geom_webmercator":"0101000020110F00007DF9DCAB4AD562C17B27E370FA1F4D41","cartodb_georef_status":true,"cartodb_id":101,"lng":-88.6996994,"lat":32.4115944},{"name":19,"address":"1211 University Blvd","city":"Tuscaloosa","state":"AL","zip":35401,"loan_balance":750000,"payoff_date":2040,"interest_rate":"","consumer_commercial":"Consumer ","type_of_loan":"Mortgage ","employer":"C","the_geom":"0101000020E61000007EDC234072E355C053AD2AA0F59A4040","created_at":"2015-04-22T21:23:03Z","updated_at":"2015-06-01T23:08:04Z","the_geom_webmercator":"0101000020110F0000A273E939029762C17C18E8ECAEEE4D41","cartodb_georef_status":true,"cartodb_id":19,"lng":-87.5538483,"lat":
@andrewbt
andrewbt / index.html
Created June 1, 2015 23:55
Vis w/ great circles and leaflet q-cluster
https://gist.githubusercontent.com/andrewbt/ad553ea50079b69d5f25/raw/784b7792ba28c8dd7c01a1295b1505dc0c4c750c/commercial-data.json
@andrewbt
andrewbt / output.sh
Created June 10, 2015 15:04
blog error
Andrews-CartoDB-MacBook-Pro:blog athompson$ grunt serve
Running "serve" task
Running "clean:dist" (clean) task
Cleaning .sass-cache...OK
Cleaning .tmp...OK
Cleaning _site/404.html...OK
Cleaning _site/TrendMap...OK
Cleaning _site/academy-torque-js...OK
Cleaning _site/allow-robots.txt...OK
@andrewbt
andrewbt / building_downloader.sh
Last active March 3, 2016 01:01
Downloads a double-zipped shapefile from NYC Socrata, separates it, and uploads to CartoDB
#!/bin/sh
CDB_USER=$1
API_KEY=$2
v1=$(uname)
if [[ -z $CDB_USER ]]
then
echo "Missing user"
@andrewbt
andrewbt / cartojs-layercontrols.html
Last active August 17, 2016 18:35
PostGIS Spatial analysis Basic Training
<!DOCTYPE html>
<html>
<head>
<title>Lesson 2 | CARTO.js | CartoDB</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="shortcut icon" href="https://carto.com/favicon.ico" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" href="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/themes/css/cartodb.css" />
@andrewbt
andrewbt / Chained-query-post-noisoline.json
Last active August 19, 2016 20:03
Carto Super Camp
{
"query": [
"SELECT * INTO carto_geocode FROM (SELECT cdb_geocode_street_point('201 moore st, brooklyn, ny') as the_geom, 'CARTO HQ' as name) AS job",
"SELECT * INTO carto_pa_airports FROM (SELECT a.*, b.name state, b.postal FROM states_table b JOIN athompson.ne_10m_airports a ON ST_Contains(b.the_geom, a.the_geom) WHERE postal = 'PA') AS job",
"SELECT * INTO carto_nearest_airport FROM (SELECT pa.* FROM carto_pa_airports pa, carto_geocode hq ORDER BY hq.the_geom <-> pa.the_geom LIMIT 1) AS job",
"SELECT * INTO carto_philly_route FROM (SELECT r.duration, r.length, r.shape as the_geom FROM carto_geocode g, carto_driveable_airports d, cdb_route_point_to_point(g.the_geom::geometry,d.the_geom::geometry, 'car') r) AS job",
"SELECT cdb_cartodbfytable('athompson', 'carto_philly_route')",
"SELECT cdb_cartodbfytable('athompson', 'carto_nearest_airport')",
"SELECT cdb_cartodbfytable('athompson', 'carto_pa_airports')",
"SELECT cdb_cartodbfytable('athompson', 'carto_geocode')"