ndarville / d3-charts

Collection of small, reusable charts created with d3.js
7 stars 1 forks source link

(World) Map #20

Open ndarville opened 9 years ago

ndarville commented 9 years ago

Mike Bostock’s “Let’s Make a Map” tutorial.

Ditched the gradient threshold.

ndarville commented 9 years ago

Miscellaneous mapping articles:

ndarville commented 9 years ago

Threshold done in ecfe2346d48f8f3b45bd993cb977cbf27d4c9901.

ndarville commented 9 years ago

TopoJSON removes all properties by default, so you have to explicitly define them.

Using http://geojson.io keeps all the data.

ndarville commented 9 years ago

Turns out that when going from GeoJSON to TopoJSON, you can’t do this:

- json.features
+ json.objects.collection.geometries

Instead, you have to use

- json.features
+ topojson.feature(json, json.objects.collection).features

Because the path function will return an error in the first instance. Here is the different result between the two:

- >console.log(json.objects.collection.geometries[0]);
- Object {type: "Polygon", properties: Object, arcs: Array[1]}

+ >console.log(topojson.feature(json, json.objects.collection).features[0]);
+ Object {type: "Feature", properties: Object, geometry: Object}

You can access properties in both instances; the rest, not so much.

ndarville commented 9 years ago

Generalize the topojsonscript instead of relying on http://geojson.io.

topojson input.geojson \
    -o output.topojson \
    -p name_sort scalerank \
    --bbox

Example links: