Monday, August 17, 2015

A Python script to make choropleth grid maps

In May 2015, there was a sudden fad in the Dataviz community (on Twitter, anyway) for hexagonal grid-type choropleth maps. A choropleth (not "chloropleth") is a map in which areas are filled in with a color whose intensity and/or hue is proportional to a quantity; we've all seen them. The problem with traditional choropleths is they are dependent on area so that, for example, a choropleth of the United States will emphasize relatively deserted Wyoming over highly populated Massachusetts.

One recent partial solution to this has been to create choropleths with equal representations of subunits with squares or hexagons. They're still not proportional to population (attempts to solve this last hurdle generally result in ugly and/or unrecognizable maps), but they're pretty cool nonetheless.

As soon as the hub-bub started, I thought it would be relatively painless and an interesting exercise to code up a Python script that would make these choropleths. Since they're geometric, it's a cinch to output SVG vector markup. I got about 90% of the way through this project in three weeks, and then a new job and some health issues interfered. but I finally found a weekend to finish it off, in at least a beta, v.0.1 way.

The script is hosted on my GitHub, and here's the IPython notebook/Jupyter tutorial that goes along with it. (There's also a script called Colorbin that's supposed to remove the hassle from associating colors with quantities for the choropleths).

Feedback is welcome. Here are some examples of what the script has produced:























• • •

25 comments:

  1. Nice results! I very much like the hexas.

    Where did you get the internet usage data for Europe?

    In the code I would advise to split functionality. Now you end up with one class containing all your logic. For example reading CSV data can be decoupled from the class. And list the imports at the start of the file, instead of in class methods.

    To get started you can find a lot of good point in the Python style guide: https://www.python.org/dev/peps/pep-0008/#imports

    ReplyDelete
    Replies
    1. > Where did you get the internet usage data for Europe?

      I'm afraid I don't recall! I lost track of where that came from.

      > For example reading CSV data can be decoupled from the class.

      Interesting... can you tell me why I would want to do this?

      > list the imports at the start of the file

      You are so right! I can't even remember why I did it that way, it was probably some sort of stopgap measure as I was developing the individual methods. How embarrassing!

      Delete
  2. This is really an amazing read about the programming and I like the intro about the python language. As i owned the website development company I understand the need of website and languages in present Digital time. I just want to say thanks for sharing all this info with us.

    ReplyDelete
  3. Gaining Python certifications will validate your skills and advance your career.
    python certification

    ReplyDelete
  4. Currently Python is the most popular Language in IT. Python adopted as a language of choice for almost all the domain in IT including Web Development, Cloud Computing (AWS, OpenStack, VMware, Google Cloud, etc.. ),Read More

    ReplyDelete
  5. RaksasaPoker Agen Domino Server Terbaru dan BandarQ Terpercaya Indonesia
    Website Judi Online Yang memberikan Pelayanan Terbaik dan mempunyai Server Yang Berkualitas Di Dalam Permainan Asli tanpa Robot Ataupun Admin Ikut Serta Bermain Serta Memberikan Kemudahan Dalam Melakukan Proses Transaksi Deposit Dan Wirthdaw Hanya 2 Menit Dana Anda Pasti Sudah Di Proses.

    BandarQ

    Domino99

    Capsa

    Agen Poker

    Agen Domino99

    Agen Capsa

    Gabung Sekarang Juga Dan Dapatkan Ratusan Juta Bersama Kamihttps://akhsadew.blogspot.comAC

    ReplyDelete
  6. RaksasaPoker Agen Domino Server Terbaru dan BandarQ Terpercaya Indonesia
    Website Judi Online Yang memberikan Pelayanan Terbaik dan mempunyai Server Yang Berkualitas Di Dalam Permainan Asli tanpa Robot Ataupun Admin Ikut Serta Bermain Serta Memberikan Kemudahan Dalam Melakukan Proses Transaksi Deposit Dan Wirthdaw Hanya 2 Menit Dana Anda Pasti Sudah Di Proses.

    BandarQ

    Domino99

    Capsa

    Agen Poker

    Agen Domino99

    Agen Capsa

    Gabung Sekarang Juga Dan Dapatkan Ratusan Juta Bersama Kamihttps://akhsadew.blogspot.comAC

    ReplyDelete
  7. RaksasaPoker Agen Domino Server Terbaru dan BandarQ Terpercaya Indonesia
    Website Judi Online Yang memberikan Pelayanan Terbaik dan mempunyai Server Yang Berkualitas Di Dalam Permainan Asli tanpa Robot Ataupun Admin Ikut Serta Bermain Serta Memberikan Kemudahan Dalam Melakukan Proses Transaksi Deposit Dan Wirthdaw Hanya 2 Menit Dana Anda Pasti Sudah Di Proses.

    BandarQ

    Domino99

    Capsa

    Agen Poker

    Agen Domino99

    Agen Capsa

    Gabung Sekarang Juga Dan Dapatkan Ratusan Juta Bersama Kamihttps://akhsadew.blogspot.comAC

    ReplyDelete
  8. RAKSASAPOKER SITUS POKER DAN DOMINO ONLINE TERBESAR DAN TERPERCAYA SE-INDONESIA DENGAN 8 GAME TERPOPULER

    ADUQ

    BANDARQ

    BANDAR POKER

    CAPSA SUSUN

    DOMINO99

    POKER ONLINE

    SAKONG ONLINE

    BANDAR66

    Gabung Dan Jadilah Jutawan Bersama Kami www.raksasapkr.net Dengan Rating Kemenangan Sebesar 90% Sekarang Juga..!!

    *~* Minimal Deposit & Withdraw Rp.20.000,-. *~*

    RaksasaPOKER merupakan website judi online yang memberikan pelayanan terbaik dalam melakukan proses transaksi DEPOSIT dan WITHDRAW hanya dalam 1 menit dana anda pasti sudah diproses dan mempunyai server yang berkualitas di dalam permainan asli 100% tanpa ROBOT/ADMIN yang ikut serta bermain.

    Link Alternatif Resmi Kami ;
    -*- http://raksasapkr.net/?ref=210514badai
    -*- http://raksasapkr.org/?ref=210514badai
    -*- http://raksasapkr.com/?ref=210514badai

    Tunggu Apalagi GUYS ? Langsung Saja Daftarkan Diri Anda Di RaksasaPOKER..!!
    Bagaimana Cara Mendaftar? GAMPANG KOK..!!
    Cukup Kunjungi Link Alternatif Resmi Kami Diatas☝
    Lalu Klik Daftar dan Daftarkan Diri Anda Segera^_^

    UNTUK INFO LEBIH LANJUT HUBUNGI KAMI MELALUI ;
    -*- LIVE CHAT : WWW.RAKSASAPKR.NET
    -*- WA : +6283151243854

    ReplyDelete
  9. I learned World's Trending Technology from certified experts for free of cost. I got a job in decent Top MNC Company with handsome 14 LPA salary, I have learned the World's Trending Technology from Data science training in btm layout experts who know advanced concepts which can help to solve any type of Real-time issues in the field of Python. Really worth trying Freelance SEO Expert in bangalore

    ReplyDelete