• Stars
    star
    219
  • Rank 181,133 (Top 4 %)
  • Language
    Python
  • License
    MIT License
  • Created over 4 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple yet highly configurable Mastodon/Twitter bot that posts geotagged aerial imagery of a random location in the world.

ærialbot

A simple yet highly configurable Mastodon/Twitter bot that posts geotagged aerial imagery of a random location in the world.


In a bit more detail, whenever you run ærialbot, it...

  • loads a shapefile from disk,
  • efficiently generates a random point꙳ within the bounds of this shape,
  • figures out which map tiles need to be downloaded to cover a certain area around the point in sufficient꙳ detail,
  • downloads those map tiles from a provider of your choice real fast (a threadpool is involved!),
  • stitches them together and crops the resulting image to precisely match the configured area,
  • saves that to disk,
  • and tweets and/or toots the image, optionally with a geotag.

As of November 2022, I've migrated all ærialbot instaces I had been running to Mastodon – follow them at @[email protected] if you like.

You can also take a look at their now-silent Twitter equivalents...

  • 🇺🇸 @americasquared, which tweets a satellite view of a randomly selected square mile of the United States once daily (examples shown below).
  • 🇰🇷 @baekmanpyeong, which tweets a square sized one million (백만, baekman) pyeong (평, traditional Korean area unit, roughly 3.3058 m²), i.e. 1.818×1.818 km, somewhere in South Korea once each day.
  • 🗾 @nihonmusuukei (Nihon mu sū kei = 日本無数景 ≈ 日本∞景, countless views of Japan), which tweets a square kilometer of Japan every day.
  • 🇩🇪 @zehnhektar, which tweets a square sized 316×316 meters (Zehn Hektar = ten hectacres) somewhere in Germany every 24 hours.
  • 🌍 @placesfromorbit, a "worldwide" instance that tweets a 5×5 km square every 6 hours.
  • 🌆 @citiesatanangle, an instance that tweets tightly-zoomed 45-degree views of (sub)urban areas around the world every 12 hours.

...and still-active instances run by others (let me know if you want yours to be included):

  • 🇩🇰 @DanskKvadrat (run by @Wegge), which focuses on Denmark and tweets a 2×2 km square every 4 hours.
  • 🇷🇴 @AerianRobot (not sure who runs it), which tweets a square-shaped portion of Romania twice each day.
  • 🇳🇱 @NL_kwadraat (run by @michelbinkhorst), which tweets a 2×2 km square of the Netherlands three times each day.
  • 🇳🇱 @amsUpTop (run by @kns008), which tweets a random square of Amsterdam or its surroundings once a day.
  • 🇹🇷 @turkeyfromorbit (run by @btutal and also active on Instagram), where an ærialbot instance tweets square-kilometer-sized satellite images of Turkey while an earthacrosstime instance posts videos as described in the next sentence.

I've set up a Twitter list, enabling you to check out (and perhaps follow) all of them.

Also check out @earthacrosstime (newly also posting on @[email protected]), a "sibling" bot that posts timelapse videos showcasing how random locations in the world have changed since 1984.

One square mile each, somewhere in the United Sates, centered around (from top left to bottom right): 31.056747601478456,-89.61225567756193; 26.44943037843055,-97.69999657039938; 39.32223925968352,-95.06302508257909; 33.830621832157895,-102.7345327711916; 46.149781016546264,-108.95292330126662; 20.755048248172997,-156.98230879693344; 41.21859102806858,-83.97344375576749; 36.89466223259036,-89.52366337871948; 36.07100491499848,-115.26963797305373; 42.87888803844798,-113.90920385179305; 33.90737575723908,-113.46512478011427; 45.009510867796266, -117.01147828430616

Posting can be disabled, meaning that this tool can serve as a high-resolution map downloader in a pinch. It newly – as of October 2021 – supports the 45-degree imagery available on Google Maps, such as this view of Barcleona, centered on the Basílica de la Sagrada Família.

Features

Here's why ærialbot is a Good Bot:

  • Configurability: Take a look at config.sample.ini – you can supply your own shapefile (or instead define a fixed point), control output verbosity, set a different map tile provider (there's a bunch of presets, including oblique views), define the filenames of the result images, scale them to your preferred size, define the text of the tweet/toot, and more!
  • Correctness: Because neighboring meridians are closer at the poles than at the equator, uniformly sampling the allowable range of latitudes would bias the generated random points toward the poles. Instead, ærialbot makes sure they are distributed with regard to surface area. For the same reason (plus the Mercator projection), the number of map tiles required to cover an area depends on the latitude – ærialbot accounts for this, too.
  • Automatic zoom level determination: Simply define the dimensions of the desired area around the generated point – ærialbot will then take care of dialing in a (more than) sufficient zoom level.
  • Comes with batteries included: The shapefiles/ directory contains a number of shapefiles to get you started, along with a guide on preparing further shapefiles for use with ærialbot.
  • Tile grabbing performance: Multiple map tiles are downloaded in parallel, and there's a snazzy progress indicator (as you can see in the GIF below) to keep you updated on the download progress.
  • Geotagging: Tweets will be geotagged with the precise location – you can disable this, of course.
  • Logging: Keeps a log file – whether that's for debugging or reminiscing is your call. Again, you can disable this easily.

What is this? It's a progress indicator. What does it do? It indicates progress.

Usage

Setup

Being a good Python 3 citizen, ærialbot integrates with venv or similar packages to avoid dependency hell. Run the following commands to get it installed on your system:

$ git clone https://github.com/doersino/aerialbot
$ python3 -m venv aerialbot
$ cd aerialbot
$ source bin/activate
$ pip3 install -r requirements.txt

(To deactivate the virtual environment, run deactivate.)

One of the dependencies, Shapely, requires the GEOS library for performing operations on two-dimensional vector geometries, which you may need to install first as described here.

Configuration

Copy config.sample.ini to config.ini (via cp config{.sample,}.ini for some Unix wizard vibes or just with your file manager like us normals), open it and modify it based on the (admittedly wordy) instructions in the comments.

See shapefiles/README.md for advice regarding finding shapefiles of the region you're interested in and preparing them for use with ærialbot.

Feel free to file an issue if anything's unclear!

Running

Once you've set everything up and configured it to your liking, run:

$ python3 aerialbot.py

That's basically it!

If you want your bot to post at predefined intervals, use cron, runwhen or a similar tool. To make cron work with venv, you'll need to use bash and execute the activate script before running ærialbot (in this example, it runs every four hours at 30 minutes past the hour):

30 */4 * * * /usr/bin/env bash -c 'cd /PATH/TO/aerialbot && source bin/activate && python3 aerialbot.py'

Pro tip: If you want to host multiple instances of ærialbot, you don't need multiple copies of the code – multiple config files suffice: simply run python3 aerialbot.py one-of-your-config-files.ini.

Uber pro tip: Run python3 aerialbot.py --help to learn about some secret CLI options!

FAQ

Why the name?

Because it's cute and I like the "æ" ligature.

Why did you make this tool?

Because satellite imagery can be extremely beautiful, and I was looking for a way of regularly receiving high-resolution satellite views of arbitrary locations such as the center pivot irrigation farms of the American heartland or squares of the Jefferson grid in my timeline.

Note that I've built this tool (along with its predecessor gomati) during the COVID-19 pandemic – when it was, you know, just kinda nice to see the great outdoors somehow.

Does this violate Google's terms of use?

(That's only relevant if you configure ærialbot to download tiles from Google Maps, which is the default source – but other tile providers do exist.)

Probably. I haven't checked. But they haven't banned my IP for downloading tens of thousands of map tiles during development and testing, so you're probably good as long as you don't use this tool for downloading a centimeter-scale map of your country. What's more, I can't think of how an ærialbot-based bot would compete with or keep revenue from any of Google's products. (And it's always worth keeping in mind that Google is an incredibly profitable company that earns the bulk of its income via folks like you just going about their days surfing the ad-filled web.)

Is there a relevant XKCD?

You bet.

Something is broken – can you fix it?

Possibly. Please feel free to file an issue – I'll be sure to take a look!

Future Work

These are ideas more than anything else – don't expect them to be implemented any time soon.

  • Commission @smolrobots to draw a little mascot – maybe a satellite with a camera, or planet earth taking a selfie.
  • Maybe split aerialbot.py up into multiple modules, take inspiration from here. This might not be required right now, but would help if any of the ideas listed below are implemented.
  • Add an option to use OSM/Nominatim for reverse geocoding. This could go along with a refactor where a ReverseGeocoder interface is introduced, which two classes TwitterReverseGeocoder (with a constructor taking the Twitter credentials) and OsmReverseGeocoder implement. The config file would have to be extended with a reverse geocoder selection option, plus a reverse geocode string template and an explanation of the available variables (which may differ depending on the selected geocoder). This reverse geocode string would then be referencable in the tweet/toot templates.
  • In addition to GeoShape.random_geopoint, also implement a Shape.random_edge_geopoint function for generating points on the edge of polygons (and polylines), and make it available via a config setting. This would 1. help test whether a given shapefile is accurate (and whether its projection is suitable), and 2. enable posting images of coastlines or border regions, which might be interesting. Random point selection on polygon outlines would need to be done by randomly picking a segment of the outline via a distribution based on a prefix sum of the haversine distances along the outlines, then uniformly picking a point along the chosen segment (or linearly interpolating).
  • Similarly, if a shapefile with (multi)points instead of a polygon or polyline is given, randomly select a location among those points. This could be used to set up a bot that posts landmarks belonging to a certain category around the world (if such data is publicly available, that is – I'm sure OSM data could be filtered accordingly). For example: Airports.
  • Support Bing Maps as a tile source. That'd involve parametrizing how map tiles are accessed since Bing Maps doesn't use the x-y-z coordinate system favored by most every other service, instead employing its own "Quadkeys" tile indexing approach which essentially encodes a path along a quad tree.
  • Enable ærialbot to generate side views of areas with elevation data using rayshader. This would look super neat, but elevation data is probably not available at the required level of detail for most regions of the world, and I'm not sure if the available satellite imagery is aligned with reality well enough for this to look good. Probably not worth the effort.
  • Build an ambient device, probably based around a Raspberry Pi and a square display like this one, that runs a variant of ærialbot that would download and display a new image (plus metadata) every time the user taps the screen or presses a button. It could be called "πinthesky" or something even more terrible. Basically, I envision this device to take the shape of a small wooden box sitting on a shelf or mantle. (I almost certainly won't build this because I've got enough screens in my life – so feel free to steal this idea under the condition of sending me a picture of the end result!)

More Repositories

1

uji

A minimalist generative art thing – press the buttons and play with the sliders!
JavaScript
185
star
2

nyum

A simple Pandoc-powered static site generator for your recipe collection – it effortlessly turns a set of Markdown-formatted recipes into a lightweight, responsive, searchable website.
HTML
183
star
3

markdeep-slides

Build presentation slides with Markdeep and present them right in your browser.
JavaScript
170
star
4

tixyz

A minimalist three-dimensional coding environment. Control 8x8x8 dots with a single JavaScript function.
JavaScript
157
star
5

markdeep-thesis

Write your (under)graduate thesis with Markdeep and typeset it right in your browser.
JavaScript
144
star
6

google-maps-at-88-mph

Google Maps keeps old satellite imagery around for a while – this tool collects what's available for a user-specified region in the form of a GIF.
Python
123
star
7

handwriting

A SQL implementation of an ancient handwriting recognition algorithm.
TeX
79
star
8

cellular-automata-posters

Simple Python script that generates cellular automata posters as PDF files.
Python
55
star
9

scriptable-widgets

A collection of Scriptable widgets I've built.
JavaScript
43
star
10

UnicodeMathML

JavaScript-based translation of UnicodeMath to MathML that can be integrated into arbitrary HTML or Markdeep documents. An interactive "playground" allows for experimentation with the syntax and insight into the translation pipeline.
JavaScript
41
star
11

earthacrosstime

Mastodon/Twitter bot that posts videos showcasing how random locations in the world have changed since 1984.
Python
40
star
12

markdeep-diagram-drafting-board

Draft Markdeep diagrams with a live-updating preview overlaid onto your source code.
HTML
29
star
13

apple-photos-export

An Apple Photos export script.
Python
21
star
14

ffmpeg-koraktor

An occasionally-growing selection of FFmpeg invocations that have proven handy in various situations.
18
star
15

tweakpane-plugin-infodump

Infodump plugin for Tweakpane, provides a text-displaying blade with basic Markdown support intended for long descriptions (i.e., infodumps).
JavaScript
16
star
16

hashing-indexes-tikz

LaTeX packages for drawing extendible hashing indexes and linear hashing indexes using TikZ.
TeX
14
star
17

ReAD

A PHP-based reading list for web articles. Maintains a searchable archive and computes lots of stats.
PHP
10
star
18

cropcircles

A tool for cropping circular center pivot irrigation fields from aerial imagery.
HTML
9
star
19

sundryautomata

Mastodon/Twitter bot that posts a randomly generated cellular automaton every 12 hours.
Python
9
star
20

gomati

A simple Google Maps tile downloader and stitcher.
Shell
8
star
21

brachiosaurus

An incredibly basic turtle drawing tool I've built for making generative art with my BrachioGraph pen plotter.
Python
8
star
22

snooker-commentary-generator

Just a silly little toy.
JavaScript
8
star
23

vol

Simple bash script for adjusting the system volume on macOS.
Shell
7
star
24

genuary2022

Code and SVG files underlying the plotter drawings I made for #GENUARY2022.
HTML
4
star
25

spell

Haskell implementation of Peter Norvig's spelling corrector.
Haskell
4
star
26

Tumblr-Themes

The source code of any Tumblr themes I've released to the Theme Garden.
HTML
4
star
27

scripts

Various scripts that don't really necessitate their own repositories
Shell
4
star
28

dotfiles

My dotfiles, plus various other configs.
Shell
3
star
29

cpi-video-creation

A quickly-thrown-together tool for making a series of videos.
Python
3
star
30

wikipediastats

A Haskell-powered Twitter bot that posts milestones and statistics of various Wikipedias.
Haskell
2
star
31

corridor

Simple text adventure game.
Prolog
1
star
32

doersino

1
star
33

acm-boobytraps

My Python 2.7 solution of the ACM Programming Contest problem "Booby Traps", along with a map generator and a LaTeX beamer slide and TikZ map visualization generator.
Python
1
star
34

leaflet-zoom2markers

Basic Leaflet control that zooms the map to show all markers.
JavaScript
1
star
35

leichter

A bare-bones weight tracking app with a simple and responsive web interface.
PHP
1
star
36

minecraft-server-utils

A few utility bash scripts that 1. start a vanilla Minecraft server on system boot, 2. keep an up-to-date incremental backup of the world and server files, as well as daily snapshots for the history books, and 3. optionally purge old snapshots whenever disk space runs low.
Shell
1
star