Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 3.19 KB

README.md

File metadata and controls

39 lines (31 loc) · 3.19 KB

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