Git Product home page Git Product logo

meteorite-strike-d3's Introduction

meteorite-strike-d3

This project plots meteorite strikes across the globe. Each strike is marked by a circle sized and coloured to represent the meteorites relative mass. Addition information, such as the date it fell, is shown on a mouse-over (or touch) tool tip. The map can be zoomed and panned using the touch or mouse gestures (pinching and dragging). I used the D3.js library and used map data from the Natural Earth project. The project is a data visualization challenge from the freeCodeCamp curriculum.

Download the source data for meteorite strikes and world map

Download meteorite strike GeoJSON data from freeCodeCamp and download world map countries data file from Natural Earth

Prepare data using command-line tools

Unzip

unzip -o ne_50m_admin_0_countries.zip

Convert Shape file to GeoJSON

npm install -g shapefile shp2json ne_50m_admin_0_countries.shp -o ne_50m_admin_0_countries.json

Install ndjson-cli

npm install -g ndjson-cli

Remove white-space from the meteorite-strike-data.json file to make it easier to process

ndjson-cat meteorite-strike-data.json > meteorites.json

Apply a Cylindrical Sterographic projection to the map and meteorites data files

npm install -g d3-geo-projection

geoproject 'd3.geoCylindricalStereographic()' \
< ne_50m_admin_0_countries.json \ 
> countries_scaled.json
geoproject 'd3.geoCylindricalStereographic()' \
< meteorites.json \ 
> meteorites_projected.json

Convert map GeoJSON source file to a Newline Delimited JSON array of features

ndjson-split 'd.features' \
< countries_scaled.json \
> countries_scaled.ndjson

Remove unwanted properties from the map data to leave just the country name

ndjson-map 'd.properties = {Country: d.properties.NAME }, d' \
< countries_scaled.ndjson \
> countries_only.ndjson

Convert feature array back to a GeoJSON feature collection object

ndjson-reduce \
< countries_only.ndjson \ 
 | ndjson-map '{type: "FeatureCollection", features: d}' \ 
 > countries_only.json

Install TopoJson

npm install -g topojson

Combine the meteorite stike data and the world map GeoJson data and convert to TopoJson format

geo2topo \ 
strikes=meteorites_projected.json \ 
world=countries_only.json \ 
> world-meteorite-strikes.json

Present and style data in web page using D3, HTML and CSS

Set the map projection to d3.geoCylindricalStereographic

meteorite-strike-d3's People

Contributors

dickyw71 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.