Category Archives: source code

7 Days of Source Day #4 – BC Budget Visualization Tool

BC Budget Visualization Tool

Project: BC Budget Visualization Tool
Date: September, 2009
Language: Processing
Key Concepts: Data visualization, data organization, sticking it to the man

Overview:

More and more data is being released to the public every day. Big initiatives like the US data.gov and the UK’s upcoming data.hmg.gov.uk are resulting in a mountain of interesting data sets. These transparency initiatives are a step in the right direction, but we are quickly going to find ourself with a surfeit of data, and a very limited number of people with the skill set to do something with it.

One solution to this is to standardize the data so that generic tools can be built to dig into the data sets. This is a great idea – but it will take a lot of work, along with something that governments are not typically too good at: consensus.

Until that happens, tools like Processing offer another solution – make small, custom tools for individual data sets which can be built quickly and can be used specifically to work with the characteristics of a specific data set. Because Processing is fairly simple, journalists, researchers and activists can all be empowered to investigate data themselves, without having to rely on expensive or difficult to acquire resources.

This sketch is an example of how this might work. I wanted to investigate the recently announced staggering Arts & Culture cuts in my local government‘s budget, and built a simple tool to do that. All told, it took about 5 hours to gather the data, produce this tool and get the results out on the web – certainly a turnaround time that would be useful for media and for activists looking to be quick with their responses.

Getting Started:

Move the sketches into your Processing sketch folder. Open Processing and open the BCBudget sketch from the File > Sketchbook menu. You’ll find detailed instructions in the header of the main tab (the BCBudget.pde file).

Thanks:

Again, this project uses Karsten Schmidt’s amazing and incredibly useful toxiclibs.

Download: BCBudget.zip (12k)


CC-GNU GPL

This software is licensed under the CC-GNU GPL version 2.0 or later.

7 Days of Source Day #3 – tree.growth

tree.growth

tree.growth

Project: tree.growth
Date: September, 2006
Language: Processing
Key Concepts: Lindenmayer Systems, recursion, biomimicry

Overview:

NOTE: My apologies for this one being a day late. You’ll notice that I never said 7 consecutive days of source releases!

Today I’m dusting off some old code, and releasing one of my favourite projects. I had hundreds of requests for source over the years, and am finally making a public release.

Trees are uniquely suited to being simulated using computer graphics. Indeed, since the 1970s, methods to algorithmically render trees have been developed and refined to the point at which trees seen in high-quality scenes are very nearly photorealistic. For this project, rather than concentrating on realistic renderings, I was instead interested in how simple forms could capture the inherent ‘treeness’ of the real thing.

In pursuit of this goal, I developed a customized software engine which produced vector renderings of imaginary tree species. By adjusting parameters in the program, trees could be rendered with various leaf shapes and colours, with flowers or shedding leaves, and in virtually any shape from small shrubs to towering birches.

The software uses a modified version of Lindenmayer Systems, a variant of formal grammar used to model growth. L-Systems were developed by the Hungarian theoretical biologist Aristid Lindenmayer.

This release version doesn’t have bitmap or vector output built in, but it would be fairly trivial to get this hooked up and working to output high-resolution bitmaps (using Marius Watz’ TileSaver class) or .PDFs (using the standard Processing PDF library).

Archive quality prints from this series are available in my Etsy store.

Finally, this code was written in 2005 – so there is a lot of room for optimization and improvement. If you end up using or improving the code for this project, please let me know.

Getting Started:

Move the sketches into your Processing sketch folder. Open Processing and open the treegrowth sketch from the File > Sketchbook menu. You’ll find detailed instructions in the header of the main tab (the treegrowth.pde file).

Thanks:

When I was getting started with Processing, I got a lot of help from the community over at Processing.org. I’d also like to thank Casey and Ben and all of the Processing team who have put so many hours into making this tool. It really is something special.

Download: tree_growth.zip (140k)


CC-GNU GPL

This software is licensed under the CC-GNU GPL version 2.0 or later.

7 Days of Source Day #2: NYTimes 365/360

NYTimes: 365/360 - 2009 (in color)

Project: NYTimes 365/360
Date: February, 2009
Language: Processing
Key Concepts: Data Visualization, NYTimes Article Search API, HashMaps & ArrayLists

Overview:

Many have you have already seen the series of visualizations that I created early in the year using the newly-released New York Times APIs. The most complex of these were in the 365/360 series in which I tried to distill an entire year of news stories into a single graphic. The resulting visualizations (2009 is picture above) capture the complex relationships – and somewhat tangled mess – that is a year in the news.

This release is a single sketch. I’ll be releasing the Article Search API Processing code as a library later in the week, but I wanted to show this project as it sits, with all of the code intact. The output from this sketch is a set of .PDFs which are suitable for print. Someday I’d like to show the entire series of these as a set of 6′ x 6′ prints – of course, someday I’d also like a solid-gold skateboard and a castle made of cheese.

That said, really nice, archival quality prints from this project (and the one I’ll be releasing tomorrow) are for sale in my Etsy shop. I realize that you’ll all be able to make your own prints now (and you are certainly welcome to do so) – but if you really enjoy the work and want to have a signed print to hang on your wall, you know who to talk to.

Getting Started:

Put the folder ‘NYT_365_360’ into your Processing sketch folder. Open Processing and open the sketch from the File > Sketchbook menu. You’ll find detailed instructions in the header of the main tab (the NYT_365_360.pde file).

Thanks:

Most of the credit for this sketch goes to the clever kids at the NYT who made the amazing Article Search API. This is the gold standard of APIs, and really is a dream to use. As you’ll see if you dig into the code, each of these complicated graphics is made with just 21 calls to the API. I can’t imagine the amount of blood, sweat, and tears that would go into making a graphic like this the old-fashioned way.

Speaking of gold standards, Robert Hodgin got me pointed to ArrayLists in the first place, and has been helpful many times over the last few years as I’ve tried to solve a series of ridiculously simple problems in Processing. Thanks, Robert!

Download: NYT365.zip (140k)


CC-GNU GPL

This software is licensed under the CC-GNU GPL version 2.0 or later.

7 Days of Source Day #1: GoodMorning!

GoodMorning! Pinheads

Project: GoodMorning!
Date: August, 2009
Language: Processing
Key Concepts: Spherical coordinates, latitude & longitude conversion, Twitter API, MetaCarta API

Overview:

GoodMorning! is a global Twitter visualization tool. It allows tweets to be placed geographically and temporally, showing how a word or phrase is used around the world over a certain time period. You can watch a video here.

The project consists of two Processing sketches: a small sketch called TwitGather to gather tweets from the Twitter API and store them with location data in a JSON file, and a larger sketch which renders that data, and allows for export as .MOV and hi-res bitmap files. I’ve included a sample file which holds about 24 hours of ‘Good morning’ tweets.

This is likely the most complicated project that I will be releasing this week. I have tried to document the sketches as thoroughly as possible, but it may be confusing for beginners. However, there are lots of fairly simple things that can be gleaned by looking at various parts of the code.

To compile this project, you’ll need to make sure you have all of the libraries and other dependencies outlined below.

Getting Started:

Move the sketches into your Processing sketch folder. Open Processing and open the GoodMorning sketch from the File > Sketchbook menu. You’ll find detailed instructions in the header of the main tab (the GoodMorning.pde file).

Thanks:

GoodMorning uses a variety of libraries, to the authors of which I am extremely grateful:

  1. Karsten Schmidt’s toxiclibs coreutils for storing coordinates and doing vector math
  2. Andreas Köberle and Christian Riekoff’s surfaceLib for rendering the planet and cloud layer
  3. Yusuke Yamamoto’s excellent Twitter4J library for talking to the Twitter API (this library is included in the download)
  4. Marius Watz’ TileSaver class, which lets you output huge bitmaps from any Processing sketch.

Download: GoodMorning.zip (10.0MB)


CC-GNU GPL

This software is licensed under the CC-GNU GPL version 2.0 or later.

A Thanksgiving Gift – 7 Days of Source Code

On Friday I attended a talk at Simon Fraser University‘s Surrey campus by NYU’s Ken Perlin. I use derivations of Ken’s famous noise function almost every day, so it was nice to get a chance to see him discuss his work. The talk also got me thinking about the value of open source and I realized I haven’t been quite as good at releasing source from my own projects as I would have liked.

It’s Thanksgiving weekend in Canada – and while I’d love to send a turkey to Ken and all of the others whose excellent libraries, algorithms and methodologies I use every day, it’s just not practical (not to mention messy). Instead, I’ve decided to release source code for 7 of my projects over the next 7 days. The first release will come some time tomorrow morning (offering a clue to which project might be dropped first).

When it comes to releasing source code, I’ve always been torn. I really believe in the philosophy of open source, but I’m intimidated by putting my code out there for everyone to see. Underneath it all, I’m probably scared of being exposed as some kind of a charlatan (“You call that programming?”). So, to pre-empt that possibility, I’ll start by saying this: I’m not a great programmer. My code is clean and fairly well-structured, but don’t expect to find any particularly advanced code wizardry or complicated mathematics. I do, however, think that the projects that I’ll be sharing over the week contain some good ideas, and a lot of helpful techniques. Hopefully you’ll find one or all of them useful.

With each release, I’ll be providing some basic documentation a brief thank-you list to the people whose code made the project possible. I’m not asking for anything in return, but I will ask that if some part any of the releases ends up being used for something new and interesting, to please let me know.