Source code for a twitter bot that tweets random small-scale satellite images of Chicago every hour. Heavily sourced from and inspired by @londonmapbot created by @mattdray.
There's one deviation from @londonmapbot that had to be implemented due to the physical geography of Chicago. When the script generates a random set of lat/lon coordinates within Chicago's bounding box, there's a good chance of it being on Lake Michigan. To avoid tweeting an image of water, I used {sf} and {geojsonsf} to load the municipal polygon boundary of Chicago (from Chicago's Open Data Portal) and check if the initial random lat/lon point intersects Chicago's municipal boundary. If the initial random point doesn't intersect, the script generates new random points until it does.
- Github Actions (scheduled to run the scripts every hour)
- Create random point
- Does it intersect with Chicago's boundary? If not, generate a new point until it does.
- Mapbox API (gets satellite imagery)
- Twitter API via {rtweets} (posts tweet)