Git Product home page Git Product logo

cartograms's Introduction

Cartogram generation code

How to get started:

  • Install PostgreSQL and PostGIS.

  • Load the standard SRSs, if they’re not already loaded:

     psql < /usr/local/share/postgis/spatial_ref_sys.sql
    
  • Add World Robinson as well:

     # from http://spatialreference.org/ref/esri/54030/postgis/
     psql <<END
     INSERT into spatial_ref_sys (
         srid, auth_name, auth_srid,
         proj4text, srtext
     ) values (
         954030, 'esri', 54030,
         '+proj=robin +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs ',
           'PROJCS["World_Robinson",GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Robinson"],PARAMETER["False_Easting",0],PARAMETER["False_Northing",0],PARAMETER["Central_Meridian",0],UNIT["Meter",1],AUTHORITY["EPSG","54030"]]'
     );
     END
    
  • (Note that PROJ.4 < 4.8 has an error in its implementation of the Robinson projection: http://trac.osgeo.org/proj/ticket/113)

  • Create the schema using sql/schema.sql and define the functions using sql/functions.sql.

  • Load whatever maps you intend to use from sql/maps.sql, or define your own.

  • Prepare your dataset in CSV format.

  • Run bin/load-data.py to load your data into the database.

  • Run bin/density-grid.py to export a density grid.

  • Run cart to create a cartogram grid from it.

  • Run bin/as-js.py to generate a JSON file of SVG path data.

  • Use this JSON data to make a beautiful web app.

A script for making cartograms from multiple datasets might look something like this:

CART=/usr/local/cartograms  # Or wherever you have installed it
for dataset in foo bar baz # Whatever your datasets are called
do
    "$CART"/bin/delete-data.py "myproject:$dataset"  # Replace “myproject” with your project name
    "$CART"/bin/load-data.py "myproject:$dataset" "data/input/$dataset.csv" countries-10m-3.1.0 Alpha-2 Value

    "$CART"/bin/density-grid.py --dataset=myproject:"$dataset" --map=world-10m-3.1.0-robinson > data/cart/density/"$dataset".density

    cart 1500 750 data/cart/density/"$dataset".density data/cart/output/"$dataset".cart

    "$CART"/bin/as-js.py --map=world-10m-3.1.0-robinson data/cart/output/"$dataset".cart -o data/output/"$dataset".js
done

cartograms's People

Contributors

robinhouston avatar theduncanclark avatar

Stargazers

Bianca avatar Chaofan Yang avatar Tom Longmate avatar iain avatar Nick Evershed avatar 明月三千里 avatar Timo Grossenbacher avatar saidimu apale avatar William Mayner avatar Benjamin Wiederkehr avatar Paul Mison avatar Christopher Humphries avatar Attila Szász avatar Dave Nolan avatar Alan Garcia avatar Drew Dara-Abrams avatar

Watchers

 avatar Alan Garcia avatar James Cloos avatar du5l5ljason avatar Kiln avatar 明月三千里 avatar  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.