Skip to content

nejohnson2/google-getter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

google-getter

CLI tool that picks a random point on Earth, fetches a Google Maps satellite image, classifies pixels into land-cover categories, and recolors the image using a randomly selected art palette. Outputs a styled PNG with embedded coordinate metadata.

Setup

Prerequisites

  • Python 3.11+
  • A Google Maps API key with the Maps Static API enabled

Installation

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

API Key

Copy the example env file and add your key:

cp .env.example .env
# Edit .env and replace your_key_here with your actual API key

Your Google Cloud project must have the Maps Static API enabled. You can enable it at: Google Cloud Console → APIs & Services → Library

Usage

# Basic: 5km x 5km area at a random location
python main.py --area 5

# Reproducible run with a fixed seed
python main.py --area 10 --seed 42

# Custom output filename
python main.py --area 2 --output my_art.png

Arguments

Argument Required Description
--area Yes Geographic area in km (e.g., 5 for ~5km x 5km)
--seed No Random seed for reproducible runs
--output No Output filename (default: output_<lat>_<lon>.png)

How It Works

1. Random Point

Selects a uniformly distributed point on Earth's surface using arcsine sampling to avoid polar bias.

2. Satellite Fetch

Converts the area (km) to a Google Maps zoom level and fetches a 640x640 satellite image via the Static Maps API.

3. Pixel Classification

Classifies each pixel into one of six land-cover categories using HSV color thresholds:

Category What it detects
Snow/Ice Very bright, low saturation
Water Blue hues
Vegetation Green hues
Desert/Sand Yellow-tan hues
Urban/Built Gray, low saturation
Bare Earth Everything else (fallback)

4. Palette Recoloring

Each thematic class is mapped to a color from a randomly chosen palette. The classification percentages and selected palette are logged to the console.

5. Output

Saves a PNG with embedded metadata (readable with any PNG metadata viewer):

  • Latitude / Longitude
  • Area (km) and zoom level
  • Palette name

Available Palettes

Palette Style
Mondrian Primary color blocks
Bauhaus Bold geometric
Pastel Dream Soft pastels
Earth Tones Natural muted
Sunset Warm gradient
Nord Arctic cool
Solarized Ethan Schoonover
Retro 70s Orange/brown warmth
Vaporwave Neon synthwave
Ocean Marine blues
Forest Deep woodland
Candy Bright sweets

Reading Image Metadata

from PIL import Image
img = Image.open("output_14.352849_150.059797.png")
print(img.text)
# {'latitude': '14.352849', 'longitude': '150.059797', 'area_km': '5.0', ...}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages