Skip to content

ucsb-dreamlab/readmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Map Extent Extractor & Georeferencer

This repository contains a suite of R tools, including a Shiny web application and command-line scripts, designed to process scanned map images (specifically .tif files). The primary goals are to extract geographic extents using the Google Gemini Vision API, detect map corners, and georeference the map to create interactive web visualizations.

Features

  • Shiny Web Interface (app.R): A user-friendly web interface that uses your local opencode CLI to read a local .tif map and extracts the map's extent in degrees and minutes by reading its corners.
  • Command-Line Extractor (cli.R): A CLI alternative to the Shiny app for headless extraction of map extents via opencode.
  • Georeferencing (georeference.R): Uses Ground Control Points (GCPs) to attach spatial references to the scanned map, warps it to Web Mercator projection, and generates an interactive Leaflet map (georeferenced_map.html).
  • Corner Detection & Image Processing: Various R scripts (e.g., find_corners.R, crop_corners.R, analyze_corners.R) aimed at isolating map frames, finding crosshairs, and determining pixel coordinates for georeferencing.

Requirements

System Dependencies

  • R (>= 4.0 recommended)
  • GDAL: Required for geospatial transformations.
  • ImageMagick: Required for image manipulation (magick package).

R Packages

Install the required R packages before running the scripts:

install.packages(c(
  "shiny", "magick", "bslib", 
  "sf", "terra", "leaflet", "leafem", "raster", "htmlwidgets"
))

Opencode CLI

To use the extent extraction features (app.R and cli.R), you need the opencode CLI installed and configured on your system. These scripts invoke opencode run to process the map image.

Usage

Ensure you have a .tif file (e.g., 6840s_100_r8_f-50-2-m.tif) in the working directory before running the extraction tools.

1. Shiny App

Run the Shiny app to use the graphical interface:

Rscript -e "shiny::runApp('app.R')"

Once the app is running in your browser, click Analyze Map.

2. Command Line Interface (CLI)

To use the CLI, simply run the script:

Rscript cli.R

3. Georeferencing

If you have predetermined Ground Control Points (as configured in the script), you can georeference the image and generate an interactive Leaflet map:

Rscript georeference.R

This will produce a georeferenced_map.html file that you can open in any web browser to view the map overlaid on standard map tiles.

About

an agenticly coded scanned map georeferencer that runs in a coder workspace with opencode configured with access to gemini

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors