Show HN: Python-based Twitter bot that posts aerial imagery of a random location

Show HN: Python-based Twitter bot that posts aerial imagery of a random location

A simple but extremely configurable bot that tweets geotagged aerial imagery of a random plan throughout the world.

In comparatively further element, each time you scramble ærialbot, it…

  • lots a shapefile from disk,
  • generates a random level꙳ throughout the bounds of this form,
  • figures out which map tiles should be downloaded to quilt a selected house across the level in sufficient꙳ element,
  • downloads these map tiles from a provider of your substitute correct snappy (a threadpool is enthusiastic!),
  • stitches them collectively and crops the ensuing picture to exactly match the configured house,
  • saves that to disk,
  • and tweets the picture, optionally with a geotag.

Look at out the following lively ærialbot circumstances (let me know in case you would handle yours to be included):

  • 🇺🇸@americasquared, which tweets a satellite tv for pc television for laptop peek of a randomly chosen sq. mile of the US each Four hours (examples proven below).
  • 🇰🇷@baekmanpyeong, which tweets a sq. sized a million (백만, baekman) pyeong (평, frail Korean house unit, roughly 3.3058 m²), i.e. 1.818×1.818 km, someplace in South Korea each eight hours.
  • 🇩🇰@DanskKvadrat (scramble by @Wegge), which focuses on Denmark and tweets a 2×2 km sq. each Four hours.
  • 🇳🇱@amsUpTop (scramble by @kns008), which tweets a random sq. of Amsterdam or its atmosphere as quickly as a day.
  • 🗽@MarenBeam, who has been using ærialbot to tweet tightly-zoomed views of The huge apple.
  • 🌍@placesfromorbit, a “worldwide” event that tweets a 5×5 km sq. each 6 hours.

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


Proper right here is why ærialbot is a Accurate Bot:

  • Configurability: Respect conclude a gaze at config.pattern.ini – it’s doubtless you will presumably provide your keep shapefile (or in its place outline a fixed level), administration output verbosity, house a assorted map tile provider, outline the filenames of the photographs, scale them to your most traditional measurement, outline the textual hiss materials of the tweet, and further!
  • Correctness: As a result of neighboring meridians are nearer on the poles than on the equator, uniformly sampling the allowable differ of latitudes would bias the generated random points in opposition to the poles. In its place, ærialbot makes specific they’re allotted nearly floor house. For the the identical purpose (plus the Mercator projection), the amount of map tiles required to quilt an house relies upon upon on the latitude – ærialbot accounts for this, too.
  • Computerized zoom stage resolution: Merely outline the size of the required house across the generated level – ærialbot will then map conclude care of dialing in a (further than) sufficient zoom stage.
  • Comes with batteries included: The shapefiles/ itemizing selections a amount of shapefiles to earn you began, along side a e-book on preparing further shapefiles for use with ærialbot.
  • Tile grabbing efficiency: Just a few map tiles are downloaded in parallel, and there may very well be a snazzy development indicator (as a result of it’s doubtless you will presumably survey throughout the GIF below) to guard you up to date on the obtain development.
  • Geotagging: Tweets would possibly per likelihood be geotagged with the precise plan – it’s doubtless you will presumably disable this, for positive.
  • Logging: Retains a log file – whether or not or not that’s for debugging or reminiscing is your identify. As soon as extra, it’s doubtless you will presumably disable this with out concerns.

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



Being an accurate Python 3 citizen, ærialbot makes use of venv to stay away from dependency hell. Escape the following directions to earn it put in in your machine:

$ git clone
$ python3 -m venv aerialbot
$ cd aerialbot
$ provide bin/set off
$ pip3 arrange -r necessities.txt

(To deactivate the digital ambiance, scramble deactivate.)


Copy config.pattern.ini to config.ini, originate it and regulate it consistent with the (admittedly wordy) directions throughout the suggestions.

Gaze shapefiles/ for recommendation referring to discovering shapefiles of the plan you’re enraged by and preparing them for use with ærialbot.


Whether it is doubtless you will even have house each little factor up and configured it to your liking, scramble:

That is usually it!

In the event you would handle your bot to tweet at predefined intervals, exhaust cron, runwhen or a the identical utility. To fabricate cron work with venv, prospects are you will perhaps have to exhaust bash and enact the set off script earlier than working ærialbot (on this occasion, it runs each 4 hours at 30 minutes earlier the hour):

30 */4 /usr/bin/env bash -c 'cd /PATH/TO/aerialbot && provide bin/set off && python3'

Expert tip: In the event you would handle to host further than one circumstances of ærialbot, you accomplish not need further than one copies of the code – further than one config recordsdata suffice: merely scramble python3 one-of-your-config-recordsdata.ini.


Why the set up?

As a result of it’s lovely and I handle the “æ” ligature.

Why did you manufacture this utility?

As a result of satellite tv for pc television for laptop imagery might maybe even be extremely lovely, and I was trying for a way of regularly receiving high-resolution satellite tv for pc television for laptop views of arbitrary areas comparable to the middle pivot irrigation farms of the American heartland or squares of the Jefferson grid in my Twitter timeline.

Reveal that I’ve constructed this utility (along side its predecessor gomati) at some stage throughout the COVID-19 pandemic – when it was, you recognize, appropriate kinda positive to move trying the massive outdoor by some functionality.

Does this violate Google’s phrases of exhaust?

(That is solely related in case you configure ærialbot to obtain tiles from Google Maps, which is the default provide – nevertheless assorted tile suppliers enact exist.)

Presumably. I’ve not checked. However they haven’t banned my IP for downloading tens of hundreds of map tiles for the duration of type and testing, so that you’re presumably appropriate as extended as you accomplish not exhaust this utility for downloading a centimeter-scale map of your nation. What’s further, I can not notify how an ærialbot-based Twitter bot would compete with or shield earnings from any of Google’s merchandise. (And it’s in total value conserving in thoughts that Google is an especially successful agency that earns the majority of its earnings by functionality of of us handle you appropriate going about their days browsing the ad-crammed web.)

Is there a relevant XKCD?

You bet.

One thing is damaged – are you able to repair it?

Presumably. Please genuinely be happy to file a matter – I’d assure to map conclude a gaze!

Future Work

These are concepts further than one factor – accomplish not predict them to be utilized any time rapidly.

  • Retry tile downloads as quickly as or twice throughout the occasion that they fail – usually, packets appropriate earn misplaced without end even when using TCP, and it may possibly even be a shame to current up which functionality of that if a bunch of tiles have already been downloaded effectively.
  • Fee @smolrobots to map a microscopic bit mascot – perhaps a satellite tv for pc television for laptop with a digicam, or planet earth taking a selfie.
  • Presumably smash up up into further than one modules, map conclude inspiration from here. This would possibly per likelihood perhaps not be required appropriate now, nevertheless would wait on if any of the concepts listed below are utilized.
  • Other than GeoShape.random_geopoint, moreover implement a Form.random_edge_geopoint characteristic for producing points on the sting of polygons (and polylines), and manufacture it available by functionality of a config atmosphere. This would possibly per likelihood 1. wait on check out whether or not or not a given shapefile is appropriate (and whether or not or not its projection is appropriate), and a pair of. allow tweeting photographs of coasts or border areas, which might be attention-grabbing. Random level substitute on polygon outlines would should be achieved by randomly selecting a section of the outline by functionality of a distribution consistent with a prefix sum of the haversine distances alongside the outlines, then uniformly selecting a level alongside the chosen section (or linearly interpolating).
  • Equally, if a shapefile with (multi)points as opposed to a polygon or polyline is given, randomly determine a plan amongst these points. This would possibly perhaps even be frail to house up a Twitter bot that tweets landmarks belonging to a selected class world enormous (if such information is publicly available, that’s – I’m specific OSM records would possibly perhaps even be filtered accordingly).
  • Allow ærialbot to generate side views of areas with elevation information using rayshader. This would possibly per likelihood look sizable good, nevertheless elevation information would possibly perhaps additionally not be available on the required stage of element for many areas of the world, and I’m not specific if the available satellite tv for pc television for laptop imagery is aligned with actuality neatly sufficient for this to move trying appropriate. Presumably not definitely worth the hassle.
  • Residing up a Japan-focused event at @nihonmusuukei (?) with shroud shroud set up “日本∞景” or “日本無数景”, i.e. “so lots of/so lots of views of Japan” in reference to Hiroshige’s collection of 100 woodblock prints.


Please enter your comment!
Please enter your name here