The Census Bureau provides a 797M shapefile for national zip code tabulation areas. Simplified using TopoJSON (with -q 1e5 -s 3e-7
), the resulting file is only 7.2M, a reduction of 99.1%. The distribution of zip codes is a rough proxy for population density. Part of the U.S. Atlas project.
Zip Codes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: gpl-3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<img src="readme.png" width="960" height="500"> |
I used https://github.com/mbostock/us-atlas
and ran make shp/us/zipcodes-unmerged.shp
to get a shapefile for us zip code boundaries.
When I ran this to get topojson...
topojson -o zips.json -q 1e5 -s 3e-7 shp/us/zipcodes-unmerged.shp
...I got this:
<--- Last few GCs --->
6606 ms: Scavenge 1398.4 (1458.0) -> 1398.4 (1458.0) MB, 0.5 / 0 ms (+ 6.6 ms in 1 steps since last GC) [allocation failure] [incremental marking delaying mark-sweep].
7190 ms: Mark-sweep 1398.4 (1458.0) -> 1398.3 (1458.0) MB, 584.1 / 0 ms (+ 11.0 ms in 5 steps since start of marking, biggest step 6.6 ms) [last resort gc].
7772 ms: Mark-sweep 1398.3 (1458.0) -> 1398.3 (1458.0) MB, 581.7 / 0 ms [last resort gc].
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x21cfaeab4629 <JS Object>
1: /* anonymous */(aka /* anonymous */) [/usr/local/lib/node_modules/topojson/node_modules/shapefile/shp.js:~92] [pc=0x1d09df473a1e] (this=0x21cfaea041b9 <undefined>,record=0x130f64716379 <an Uint8Array with map 0x6eeee4048e9>)
2: readRecord(aka readRecord) [/usr/local/lib/node_modules/topojson/node_modules/shapefile/shp.js:40] [pc=0x1d09df462fe7] (this=0x21cfaea041b9 <undefined>,error=...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
Aborted (core dumped)
Any idea what's going on?
Do you have the topoJSON stored in a repository? I would like to use it for a visualization and need the link to the file. Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I followed the reduction using topojson---but what did you use for rendering the PNG? Also, would an SVG of this size and complexity be suitable for an interactive graphic with D3, if I had to do dynamic coloration on the fly? Or is this something you'd recommend processing to non-vector format first, such as you have here?