Skip to content

pfitzpaddy/d3jsworld

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

D3jsworld

D3js World is an interactive map example based on the D3js library created by mbostock that includes location image icons, zoom, pan & jQuery chosen drop down country selection.

The demo lends heavily from the excellent d3js map tutorial as well as the many b.locks and d3js tutorials from mbostock that demonstrate d3js usage.

Data Preparation

Prerequisites

The following are prerequisites are required to prepare custom TopoJSON datasets;

The Geospatial Data Abstraction Library (GDAL) is used primarily for ogr2ogr data transformations.

mbostock has designed TopoJSON as an extension to GeoJSON where geometries are not encoded discretely - if geometries share features, they are combined (such as borders). Additionally TopoJSON encodes numeric values more efficiently and can incorporate a degree of simplification. This simplification can result in savings of file size of 80% or more depending on the area and use of compression.

Data Source

Natural Earth provides a variety of cultural, physical and raster datasets maintained by cartographer Nathaniel Vaughn Kelso (and others). Shapefiles are beautifully simplified by hand for different resolutions, letting you choose the resolution appropriate to your application.

Filtered by capital cities.

Processing

The Shapefiles from Natural Earth are converted to GeoJSON format and then TopoJSON.

~# ogr2ogr -f GeoJSON -select oid_,iso_a2,iso_a3,subunit,pop_est output.json input.shp
~# topojson -p OID_,ISO_A2,ISO_A3,SUBUNIT,POP_EST -o output.json -- admin0=input.json/input.shp

Notes

TopoJSON

  • If the properties parameter (-p) is left blank then no attributes are included in the TopoJSON.
  • The attributes entered using the properties parameter (-p) are CASE SENSITIVE to those in the input file
  • To specify the object name within the generated TopoJSON file, prefix the input file with “name=”
~# topojson -p OID_,ISO_A2,ISO_A3,SUBUNIT,POP_EST -o output.json -- admin0=input.json/input.shp

Simplification

  • TopoJSON includes a parameter for polygon simplification using the Visvalingam algorithm.
~# topojson -p OID_,ISO_A2,ISO_A3,SUBUNIT,POP_EST --simplify-proportion 0.8 -o output.json input.json/input.shp

About

A d3js world map example...

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published