Skip to content

Instantly share code, notes, and snippets.

View jczaplew's full-sized avatar

John J Czaplewski jczaplew

View GitHub Profile
@jczaplew
jczaplew / README.md
Created October 2, 2013 18:40
Adaptive Composite Map Projection (Canvas)
@jczaplew
jczaplew / README.md
Last active February 17, 2017 05:20
Lazy composite

Display global views using a Hammer projection with d3.js, everything else in a web mercator with Leaflet.js.

Edit: now with additional smoke and mirrors.

@jczaplew
jczaplew / README.md
Last active July 25, 2016 05:46
Detecting double taps with d3.js

A simple example showing how to detect a double tap with d3.js, and an accompanying method for reusability.

@jczaplew
jczaplew / README.md
Created October 28, 2013 20:36
Topojson Paleogeography (normal order)

GeoJSON plates render correctly, whereas the TopoJSON plates do not. The plate that wraps the north pole is inverted, covering all of the oceans.

@jczaplew
jczaplew / README.md
Created October 28, 2013 20:44
Topojson Paleogeography (reversed latitudes)

In contrast to the other example (http://bl.ocks.org/jczaplew/7204160), this example uses the same data, but with all latitudes in the GeoJSON file flipped before converting to TopoJSON. This results in the GeoJSON rendering incorrectly, but the TopoJSON rendering correctly.

@jczaplew
jczaplew / README.md
Last active January 18, 2021 21:02
Geologic Time Scale
@jczaplew
jczaplew / README.md
Last active December 28, 2015 22:39
Pole-wrapping geometry issue

These three maps demonstrate that under some conditions, the winding order of large polygons that wrap the poles is incorrectly guessed by D3. Converting to Topojson (topojson -o plates.topojson -p --no-stitch-poles -- plates.geojson) forces a consistent winding order (see https://github.com/mbostock/d3/wiki/Geo-Paths#wiki-_path), but in this case does not fix the problem.

It is also important to note that this error only throws an error in Chrome Canary and simply does not draw the problematic polygon, whereas in every other browser (Chrome Stable, Firefox, Safari) no error is thrown to the console and the problematic polygon is draw with the wrong winding order.

@jczaplew
jczaplew / import.sh
Created November 26, 2013 00:08
Bulk import SHP into PostGIS
#! I need this for my broken version of Postgres.app
#!export DYLD_LIBRARY_PATH=/Applications/Postgres.app/Contents/MacOS/lib/
for i in *.shp; do
shp2pgsql -s 4326 $i | psql -h localhost -U you -d database
done
@jczaplew
jczaplew / postgis2geojson.py
Last active March 23, 2023 19:08
A tool for extracting data from PostGIS into GeoJSON and TopoJSON. UPDATE: Added a dedicated repo for contributions - https://github.com/jczaplew/postgis2geojson
'''
A simple tool for exporting from a PostGIS table to GeoJSON and TopoJSON. Assumes Python 2.7+,
psycopg2, and TopoJSON are already installed and in your PATH.
Adapted from Bryan McBride's PHP implementation
(https://gist.github.com/bmcbride/1913855/)
by John Czaplewski | jczaplew@gmail.com | @JJCzaplewski
TODO:
- Add argument for SRS
@jczaplew
jczaplew / herok_github.md
Last active January 11, 2023 10:41
Heroku + Github + Sensitive Data

Heroku + Github + Sensitive Data

Scenario: You deployed a Heroku project that contains sensitive data (password, API key, etc) but you want to share it on Github.

Problem: You need to commit all files necessary for the application to run on Heroku. However, pushing this to Github would reveal the sensitive info.

Solution: Have a production branch (for this example, master will be the production branch) and a Github branch. The latter contains a different .gitignore that ignores the sensitive files.