Adrià Mercader

Munibot, the friendly geo Twitter bot

December 26, 2020 | Archive

I wrote Munibot, a small Twitter bot that tweets aerial imagery of municipalities (or any other administrative region). Its current two incarnations are @munibot_es and @munibot_cat, sending regular images of municipalities in Spain and Catalonia respectively:

A screenshot of Munibot es

Original tweet

Of course it is open source and you can easily customize it to run your own. The source and documentation is on GitHub.

I was originally inspired by @everytract, which shows all US Census Tracts in order, and while working on it I also found out about a more recent colleague, @everypostcode. I’m happy Munibot joins this crew of silent tweeters that bring beautiful aerial imagery to otherwise depressing timelines.

To make things a bit more interesting I wanted to not only show the specific municipality with a white or black background but to mask the surroundings with a semi-transparent mask. I think this makes the images generated more beautiful:

Examples of images generated by Munibot
Examples of images generated by Munibot

It had been a long while since my geo days, so it was remarkable to see how libraries like Fiona and Rasterio have made it so much easier to deal with geospatial data. Tweepy made all the Twitter-specific stuff straightforward, so all in all it was relatively easy to put together.

My goal is to eventually have different bots tweeting different administrative units from places around the world, so I wrote the main library in a modular way, where different profiles feed the relevant data and Munibot takes care of all the common logic.

Profiles need to provide:

With all this Munibot will take care of the rest:

And that’s it. Once everything is set up, it just a matter of running the following:

munibot tweet <profile_name>

Next steps are to finish the documentation, and implement one or more new bots externally to really test the profiles mechanism. Do you want to run your own or know data sources that would make a good candidate for a new munibot account? Get in touch!

A screenshot of Munibot cat

Original tweet