Spatial Narrative

spatial narrative

Extract geographic narratives from text.

What It Does

spatial-narrative extracts locations and events from unstructured text, turning documents into structured geospatial data.

Input:  "The summit in Paris brought together leaders from Berlin and Tokyo.
         Negotiations continued through the week before concluding in Geneva."

Output: [
  { location: Paris (48.86°, 2.35°), text: "summit" },
  { location: Berlin (52.52°, 13.41°), text: "leaders" },
  { location: Tokyo (35.68°, 139.65°), text: "leaders" },
  { location: Geneva (46.20°, 6.14°), text: "concluding" }
]

Core Workflow

┌──────────────┐      ┌──────────────┐      ┌──────────────┐      ┌──────────────┐
│     Text     │  →   │  Geoparser   │  →   │   Narrative  │  →   │    Export    │
│  (documents, │      │  (extract    │      │   (events,   │      │  (GeoJSON,   │
│   articles)  │      │   locations) │      │   analysis)  │      │   mapping)   │
└──────────────┘      └──────────────┘      └──────────────┘      └──────────────┘

Key Features

FeatureDescription
GeoparsingExtract place names from text and resolve to coordinates
Built-in Gazetteer2,500+ world cities with coordinates, population, aliases
Coordinate DetectionParse decimal degrees, DMS, and other coordinate formats
Online GazetteersOptional Nominatim, GeoNames, Wikidata integration
Event ModelingStructure extracted locations into events with timestamps
AnalysisClustering, spatial metrics, trajectory detection
ExportGeoJSON, CSV, JSON for mapping tools

Quick Example

use spatial_narrative::parser::{GeoParser, BuiltinGazetteer};

// Create parser with built-in gazetteer (2500+ cities, no API needed)
let gazetteer = BuiltinGazetteer::new();
let parser = GeoParser::with_gazetteer(gazetteer);

// Extract locations from text
let text = "Fighting broke out near Kyiv before spreading to Kharkiv and Odesa.";
let mentions = parser.extract(text);

for mention in &mentions {
    if let Some(loc) = &mention.location {
        println!("{}: ({:.2}°, {:.2}°)", mention.text, loc.lat, loc.lon);
    }
}
// Kyiv: (50.45°, 30.52°)
// Kharkiv: (49.99°, 36.23°)
// Odesa: (46.48°, 30.73°)

Use Cases

  • Journalism: Extract locations from news articles to map story development
  • Intelligence: Geolocate events from reports and social media
  • Historical Research: Map events from historical documents
  • Disaster Response: Extract affected locations from situation reports
  • Academic Research: Ground qualitative text data in geography

Modules

ModulePurpose
parserGeoparsing: extract locations from text
coreData types: Event, Location, Timestamp, Narrative
analysisClustering, metrics, trajectory analysis
indexSpatial/temporal indexing for large datasets
graphEvent relationship networks
ioGeoJSON, CSV, JSON export

Getting Started

Ready to extract locations from text? Start with the Installation guide!