On a Saturday night, when I really should have been watching football, I noticed Vanalli and thai101 discussing the Bangkok floods on Twitter…
@Vanalli Good question. A smart coder could do a rough calc with an updated flood map. Count blue pixels vs non-blue. I’m not smart tho.
— Rikker Dõckum (@thai101) October 29, 2011
They are smart. They just aren’t Perl nerds. This is probably a good thing, as it means they don’t spend their Saturday nights writing Perl code… That would be sad. Ahem.
I hacked up a quick script that would scan through every pixel in a given image, count all of the pixels that were mostly blue, and report that back as a percentage. But I didn’t have a decent map to work from.
Soon enough though, @thai101 came up with this one (click to embiggen):
This was created by cropping Bangkok itself out of this larger image.
The script I’d put together failed on two counts - I hadn’t considered that Bangkok is not rectangular (d’oh), and I’d assumed the flood pixels would be blue. They’re not - they’re turquoise. Which means that we’re not looking for “mostly blue” pixels - we’re looking for pixels which are very blue AND very green, but not very red.
That’s why the first run came up with a figure of 9%, which looked wrong - and was.
A few tweaks later though, it turns out that 21.19% of the pixels in that cropped image, discounting the white pixels, are approximately turquoise.
This is, of course, not the most scientific of investigations:
@barryprice Text covers some areas, jpg compression fuzzies it up, and already out of date. Not ideal, but enough for a rough estimate.
— Rikker Dõckum (@thai101) October 29, 2011
But it’s the best guess I’ve seen so far.
It’d be very interesting to run it daily and see how things are developing, if we can get hold of good enough source data in a timely manner.
For now though, here’s the Perl code for anyone who wants to check my work:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
And here’s the output:
1 2 3 4 | |
Thresholds are entirely arbitrary, all errors are my own.
