Skip to content

Instantly share code, notes, and snippets.

View rgdonohue's full-sized avatar

Rich Donohue rgdonohue

View GitHub Profile
@rgdonohue
rgdonohue / README.md
Last active March 13, 2023 23:22
Locate and find nearest in Leaflet

This example queries data from CARTO, uses the geolocation API to get the user's position, and finds the nearest three features.

Note: geolocation appears blocked within bl.ocks.org.

@rgdonohue
rgdonohue / README.md
Last active November 14, 2016 14:06
Dynamic Legends in CartoDB
@rgdonohue
rgdonohue / README.md
Last active April 13, 2016 16:38
Dynamic Classification of CartoDB Choropleth Map

This technique demonstrates calculating class ranges (i.e. breaks) for dynamically coloring a choropleth requested from data hosted on CartoDB.

The solution requires two requests:

  1. first for the raw data so the full range of the data can be classified (here using the ckmeans clustering method from Simple Statistics)
  2. then to request the tiles using the generated cartoCSS rules

Data are percentages of uninsured Americans in 2015. Darker blue indicates higher percentage.

Legend comes next.

@rgdonohue
rgdonohue / README.md
Last active December 10, 2015 23:03
Perceptual scaling of prop symbols

This example shows a solution to achieve perceptual (or apparent) scaling of graduated symbols, using the Leaflet library. Data are raw totals of Kenyan girls enrolled in the 8th grade by county.

Apparently we've never been calculating the area of our circles for graduated symbols?

@rgdonohue
rgdonohue / README.md
Last active April 15, 2016 17:22
proportional hello kitty symbol map

This map demonstrates the technique of using a SVG icon to encode the relative magnitude of hydroelectric power generation plants in the US. Hello Kitty cares deeply about renewable energy.

WARNING: the use of this icon as a proportional symbol has not been scientifically tested.

Data source: Form EIA-860 http://www.eia.gov/electricity/data/eia860/index.html

@rgdonohue
rgdonohue / README.md
Last active November 25, 2015 20:52
PostGIS to include AK and HI in CartoDB

This example demonstrates the use of PostGIS to move and scale Alaska and Hawaii to fit SW off the continental US in a traditional map layout, client-side using CartoDB.js.

The continental US is first transformed out of Geo Web Mercator to an USA Contiguous Albers Equal Area Conic projection using the PostGIS function ST_Transform. Inspired by Free Your Maps From Web Mercator.

Alaska and Hawaii are then transformed using their respective projections, and then moved using St_Transform. Alaska's area is also reduced in size using the ST_Scale function.

@rgdonohue
rgdonohue / README.md
Last active January 11, 2023 21:43
Batch Geocoding Script with GeoPy
@rgdonohue
rgdonohue / README.md
Last active November 5, 2015 18:12
GeoJSON with CartoDB layer

Demonstrates loading a local data file (encoded in TopoJSON format) and symbolizes using Leaflet functionality. Also loads a data layer form CartoDB database. JQuery detects zoom level to remove or add the hexbin layer and toggle between the relevant legends/layer switcher.

@rgdonohue
rgdonohue / README.md
Last active October 31, 2015 15:00
refactored CartoDB layers switcher

Refactored creation of multiple CartoDB layers.

@rgdonohue
rgdonohue / README.md
Last active October 31, 2015 14:03
CartoDB layer switcher

Toggles between CartoDB layers. Is advantageous over sublayers in that all points are not redrawn with each toggle.