Paul Greyson | 6cb8ca0 | 2014-11-12 18:09:02 -0800 | [diff] [blame] | 1 | see: http://bost.ocks.org/mike/map/ |
| 2 | |
| 3 | brew install gdal |
| 4 | npm install -g topojson |
| 5 | |
| 6 | To generate continental US map: |
| 7 | |
Paul Greyson | fcba0e8 | 2014-11-13 10:21:16 -0800 | [diff] [blame] | 8 | $ wget 'http://www.naturalearthdata.com/download/50m/cultural/ne_50m_admin_1_states_provinces_lakes.zip' |
| 9 | $ unzip ne_50m_admin_1_states_provinces_lakes.zip |
| 10 | $ ogr2ogr -f GeoJSON -where "sr_adm0_a3 IN ('USA')" states.json ne_50m_admin_1_states_provinces_lakes.shp |
Paul Greyson | 6cb8ca0 | 2014-11-12 18:09:02 -0800 | [diff] [blame] | 11 | |
| 12 | edit states.json to remove data for Hawaii and Alaska |
| 13 | |
Paul Greyson | fcba0e8 | 2014-11-13 10:21:16 -0800 | [diff] [blame] | 14 | $ topojson states.json > topology.json |
| 15 | |
| 16 | |
| 17 | The .shp file above is incomplete (USA and part of Candada.) |
| 18 | So it may be that each region requires a bit of research to generate. |
| 19 | Ideally a source for public domain shp files can be found that covers all geographic regions. |
| 20 | |
| 21 | |
| 22 | For Canada: |
| 23 | |
| 24 | # wget 'http://www12.statcan.gc.ca/census-recensement/2011/geo/bound-limit/files-fichiers/gpr_000b11a_e.zip' |
| 25 | # unzip gpr_000b11a_e.zip |
| 26 | # ogr2ogr -f "GeoJSON" -s_srs EPSG:21781 -t_srs EPSG:4326 canada.json gpr_000b11a_e.shp |
| 27 | # topojson --id-property CFSAUID -p name=PRNAME -p name canada.json > topology.json |
| 28 | |
| 29 | |
| 30 | This produces a very large (5MB) file and draws very slowly in Chrome. |
| 31 | So some additional processing is required to simplify the geometry. (It is not checked in.) |
| 32 | |
| 33 | Also, the specification of object structure within the geojson is unclear. |
| 34 | In the US map the geojson structure is |
| 35 | |
| 36 | json.objects.states |
| 37 | |
| 38 | but in the Canadian data it's |
| 39 | |
| 40 | json.objects.canada |
| 41 | |
| 42 | |
| 43 | Lastly, the projection that is used may be tailored to the region. |
| 44 | The preferred projection for the US is "albers" and d3 provides a "albersUSA" which can be used to |
| 45 | project hawaii and alaska as well |
| 46 | |
| 47 | For Canada, apparantly a "Lambert" projection (called conicConformal in d3) is preferred |
| 48 | |
| 49 | see: |
| 50 | https://github.com/mbostock/d3/wiki/Geo-Projections |
| 51 | http://www.statcan.gc.ca/pub/92-195-x/2011001/other-autre/mapproj-projcarte/m-c-eng.htm |
| 52 | |
| 53 | |
| 54 | Summary: |
| 55 | - some additional work is required to fully generalize maps functionality. |
| 56 | - it may be worthwhile for ON.LAB to provide the topo files for key regions since producing these |
| 57 | files is non-trivial |
| 58 | |
| 59 | |
| 60 | |
Paul Greyson | 6cb8ca0 | 2014-11-12 18:09:02 -0800 | [diff] [blame] | 61 | |