Skip to content

Latest commit

 

History

History
 
 

README.md

title GEO-INFER-DATA: Geospatial Data Management, ETL, and Storage Optimization
description Foundational data backbone providing ETL pipelines, storage optimization, and data quality assurance for geospatial datasets
purpose Ensure reliable, timely access to high-quality, analysis-ready geospatial data for all GEO-INFER components
module_type Data Management
status Beta
last_updated 2025-01-19
dependencies
OPS
SEC
compatibility
GEO-INFER-SPACE
GEO-INFER-TIME
GEO-INFER-AI
GEO-INFER-APP
tags
data
etl
storage
quality
pipeline
warehouse
difficulty Intermediate
estimated_time 60

Overview

This module provides...

GEO-INFER-DATA: Geospatial Data Management, ETL, and Storage Optimization

Purpose: Foundational data backbone providing ETL pipelines, storage optimization, and data quality assurance for geospatial datasets

This module ensures that all GEO-INFER components have reliable, timely access to high-quality, analysis-ready geospatial data through robust ETL processes and optimized storage solutions.

🚀 Overview

GEO-INFER-DATA serves as the foundational data backbone for the entire GEO-INFER framework, implementing robust Extract, Transform, Load (ETL) pipelines and optimizing data storage and access to ensure all components have reliable access to high-quality geospatial data.

The module provides comprehensive data management capabilities including:

  • Multi-source data ingestion from diverse geospatial sources
  • Intelligent ETL pipelines with automatic dependency resolution
  • Adaptive data storage with multiple backend support
  • Comprehensive data validation and quality assurance
  • REST API for data access and management
  • Performance optimization and monitoring

🔗 Links

  • Module README: ../../GEO-INFER-DATA/README.md
  • Examples Directory: examples/
  • API Documentation: docs/api_schema.yaml
  • Configuration Templates: config/
  • Test Suite: tests/
  • Modules Overview: ../modules/index.md

📊 Module Status

  • Version: 1.0.0 (Beta)
  • Last Updated: 2025-01-19
  • Dependencies: OPS, SEC
  • Compatibility: GEO-INFER-SPACE, GEO-INFER-TIME, GEO-INFER-AI, GEO-INFER-APP
  • Tags: data, etl, storage, quality, pipeline, warehouse

🎯 Core Features

1. Multi-Source Data Ingestion

Intelligent data ingestion from multiple geospatial sources with automatic format detection, validation, and quality assurance.

from geo_infer_data.core.ingestion import MultiSourceDataIngestion

ingestion = MultiSourceDataIngestion(
    data_sources=['satellite', 'sensors', 'crowdsourced'],
    validation_enabled=True,
    quality_threshold=0.8
)

result = await ingestion.ingest_multi_source(
    satellite={'bbox': [-122.5, 37.7, -122.3, 37.9]},
    sensors={'time_range': '2023-01-01/2023-01-31'},
    crowdsourced={'category': 'environment'}
)

2. Intelligent ETL Pipelines

Advanced ETL workflows with automatic dependency resolution, error recovery, and performance optimization.

from geo_infer_data.core.pipeline import IntelligentETLPipeline

pipeline = IntelligentETLPipeline(
    workflow_config='etl_config.yaml',
    dependency_resolution='automatic',
    error_recovery='intelligent_retry'
)

result = await pipeline.execute_workflow(
    source_data=raw_data,
    target_storage=processed_storage,
    transformation_rules=transformations
)

3. Adaptive Data Storage

Multi-backend storage with automatic optimization based on access patterns and performance requirements.

from geo_infer_data.core.storage import AdaptiveDataStorage

storage = AdaptiveDataStorage(
    storage_backends=['postgresql', 'minio', 'redis'],
    optimization_strategy='access_pattern_based',
    compression_enabled=True
)

data_id = await storage.store_geospatial_data(data, metadata, access_patterns)
results = await storage.adaptive_query(spatial_bounds=bbox, temporal_range=range)

4. Data Quality Management

Comprehensive validation and quality assurance with trend analysis and improvement recommendations.

from geo_infer_data.core.validation import DataQualityManager

quality_manager = DataQualityManager(
    validation_rules='comprehensive',
    quality_threshold=0.85
)

report = await quality_manager.validate_dataset('dataset_123')
recommendations = quality_manager.get_improvement_recommendations(report)

5. REST API

Full-featured REST API for data access, management, and integration.

from geo_infer_data.api.rest_api import DataAPI

api = DataAPI(config_path='config/local.yaml')
api.start()  # Starts server on http://localhost:8001

# API endpoints available:
# GET /datasets - List datasets
# POST /datasets - Create dataset
# GET /datasets/{id}/data - Get dataset data
# POST /data/ingest/multi-source - Multi-source ingestion
# POST /data/etl/execute - Execute ETL pipeline

Core Objectives

  • Data Accessibility: Provide unified and efficient access to a wide variety of geospatial data sources.
  • Data Quality: Implement rigorous validation, cleaning, and quality assurance processes.
  • Interoperability: Support common geospatial data formats and standards to facilitate data exchange.
  • Scalability: Design storage and processing solutions that can scale with growing data volumes and user demands.
  • Efficiency: Optimize data pipelines and storage for rapid data retrieval and analysis.
  • Governance: Establish clear protocols for data lineage, versioning, metadata management, and access control.

Core Features

  • Distributed Geospatial Data Warehousing: Design and management of data lake and data warehouse architectures suitable for large-scale geospatial data, enabling efficient querying and analytics across diverse datasets.
    • Integration with PostGIS, MinIO, TimescaleDB, and other specialized data stores.
  • Intelligent ETL (Extract, Transform, Load) Pipelines: Configurable and automatable pipelines for ingesting data from various sources (files, APIs, databases, streams), transforming it into analysis-ready formats (e.g., projection, cleaning, feature engineering), and loading it into the data warehouse or designated storage.
    • Support for batch and stream processing.
  • Version Control for Geospatial Datasets: Mechanisms for tracking changes to datasets over time, enabling reproducibility, rollback capabilities, and collaborative data management (e.g., leveraging DVC - Data Version Control, or custom solutions integrated with Git).
  • Data Quality Assurance & Validation Workflows: Automated and manual processes for assessing data accuracy, completeness, consistency, and timeliness. Includes tools for defining validation rules and generating quality reports.
  • Metadata Management & Cataloging: Systems for capturing, storing, and querying metadata about datasets (e.g., source, lineage, schema, spatial/temporal extent, quality). Adherence to standards like ISO 19115, SpatioTemporal Asset Catalogs (STAC).
  • Data API & Access Services: Provides standardized APIs (e.g., RESTful, OGC WFS/WCS/WMS) for other modules and applications to discover, query, and retrieve geospatial data.
  • Geospatial Data Indexing: Advanced spatial and temporal indexing strategies (e.g., R-trees, Quadtrees, H3, space-filling curves) to accelerate queries and analytical operations.

Data Flow & ETL Architecture (Conceptual)

graph TD
    subgraph Data_Sources as "Data Sources"
        FILES[Files (GeoJSON, Shapefile, GeoTIFF)]
        DATABASES[Databases (PostgreSQL, External DBs)]
        APIS[APIs (STAC, OGC, Custom)]
        STREAMS[Real-time Streams (Sensors, IoT)]
    end

    subgraph ETL_Pipeline as "GEO-INFER-DATA ETL Engine"
        EXTRACT[Extract Layer]
        TRANSFORM[Transform Layer]
        LOAD[Load Layer]
        VALIDATE[Validation & QA]
        METADATA[Metadata Management]
        VERSIONING[Data Versioning]
    end

    subgraph Data_Storage_Access as "Data Storage & Access Layer"
        WAREHOUSE[Geospatial Data Warehouse]
        DB_POSTGIS[PostGIS (Vector)]
        DB_TIMESERIES[TimescaleDB (Time-Series)]
        OBJECT_STORE[Object Storage (MinIO/S3 - Raster, Files)]
        CACHE[Cache (Redis)]
        DATA_API[Data Access API]
    end

    subgraph Data_Consumers as "Data Consumers"
        ANALYSIS_MOD[Analysis Modules (SPACE, TIME, AI, ACT)]
        APP_MOD[Application Modules (APP, ART)]
        USERS[End Users / External Systems]
    end

    %% Connections
    FILES --> EXTRACT
    DATABASES --> EXTRACT
    APIS --> EXTRACT
    STREAMS --> EXTRACT

    EXTRACT --> TRANSFORM
    TRANSFORM --> VALIDATE
    VALIDATE --> LOAD
    TRANSFORM --> METADATA
    LOAD --> VERSIONING
    VERSIONING --> WAREHOUSE
    
    WAREHOUSE --- DB_POSTGIS
    WAREHOUSE --- DB_TIMESERIES
    WAREHOUSE --- OBJECT_STORE

    DB_POSTGIS --> DATA_API
    DB_TIMESERIES --> DATA_API
    OBJECT_STORE --> DATA_API
    CACHE --> DATA_API

    DATA_API --> ANALYSIS_MOD
    DATA_API --> APP_MOD
    DATA_API --> USERS

    METADATA -- "Updates" --> DATA_API

    classDef dataprocess fill:#ffe8cc,stroke:#d68400,stroke-width:2px;
    class ETL_Pipeline,Data_Storage_Access dataprocess;
Loading

Directory Structure

GEO-INFER-DATA/
├── config/              # Configuration for ETL jobs, database connections, storage endpoints
├── docs/                # Detailed documentation, data model schemas, API specs
├── etl/                 # Scripts and configurations for ETL pipelines (e.g., Airflow DAGs, Spark jobs)
├── examples/            # Example scripts for data access, ETL pipeline usage
├── src/                 # Source code
│   └── geo_infer_data/  # Main Python package
│       ├── api/         # Data access API implementations
│       ├── core/        # Core ETL logic, data processing functions, validation rules
│       ├── models/      # Pydantic models for data schemas, metadata
│       ├── connectors/  # Connectors to various data sources and storage backends
│       └── utils/       # Utility functions, helper scripts
├── storage/             # Schemas, configurations for data storage systems (e.g., PostGIS table definitions)
├── tests/               # Unit and integration tests for ETL, data access, validation
└── validation/          # Detailed data validation rule sets, quality check scripts

Getting Started

Prerequisites

  • Python 3.9+
  • Docker (recommended for running databases and other services)
  • Relevant database client libraries (e.g., psycopg2 for PostgreSQL)
  • Optionally, Apache Spark, Apache Airflow for large-scale ETL.

Installation

uv pip install -e ./GEO-INFER-DATA

Configuration

Database connection details, storage endpoint configurations, API keys for external data sources, and ETL pipeline parameters are managed in config/ (e.g., database.ini, s3_config.yaml) and/or environment variables.

# cp config/example_database.ini config/database.ini
# # Edit database.ini with your local/remote database credentials

Running Tests

pytest tests/

Supported Data Sources

A wide array of geospatial and related data sources are supported, including but not limited to:

  • Vector Data: GeoJSON, Shapefile, GeoPackage, KML, TopoJSON, WKT/WKB.
  • Raster Data: GeoTIFF (including Cloud-Optimized GeoTIFF - COG), NetCDF, HDF, Zarr, PNG, JPEG.
  • Tabular & Time Series Data: CSV, Parquet, Excel, Feather, with spatial attributes or linked to spatial features.
  • Databases: PostgreSQL/PostGIS, MySQL, SQLite, and other SQL/NoSQL databases with geospatial capabilities.
  • Web Services & APIs: OGC Standards (WMS, WFS, WCS, WPS, SOS), STAC APIs, RESTful APIs providing geospatial data (e.g., weather APIs, demographics APIs).
  • IoT Sensor Data Streams: MQTT, Kafka, or direct sensor integrations for real-time geospatial observations.
  • Open Data Portals: CKAN, Socrata, and other open government data platforms.
  • Crowdsourced Data: OpenStreetMap (OSM) extracts, data from platforms like Ushahidi or Mapillary.

Data Storage Options

GEO-INFER-DATA is designed to be flexible with storage backends, leveraging the strengths of different systems:

  • PostgreSQL with PostGIS: Primary choice for transactional vector data, complex spatial queries, and relational integrity.
  • MinIO / S3-compatible Object Storage: Scalable and cost-effective storage for large raster files, raw data archives, and intermediate ETL products.
  • TimescaleDB (PostgreSQL extension): Optimized for high-ingestion rates and complex queries on time-series data, including geospatial time series.
  • Redis: In-memory data store for caching frequently accessed data, session management, and as a message broker for real-time updates.
  • Elasticsearch/OpenSearch: For indexing and searching large volumes of textual and geospatial metadata, and for certain types of spatial queries.
  • Specialized Geospatial Databases/Engines: Potential integration with systems like GeoMesa, GeoWave for very large-scale spatio-temporal analytics on distributed key-value stores (e.g., HBase, Accumulo).

API Reference

Core Classes

MultiSourceDataIngestion

Intelligent multi-source data ingestion with automatic format detection.

from geo_infer_data import MultiSourceDataIngestion

# Initialize ingestion system
ingestion = MultiSourceDataIngestion(
    data_sources=['satellite', 'sensors', 'crowdsourced'],
    validation_enabled=True,
    quality_threshold=0.8
)

# Ingest from multiple sources
result = await ingestion.ingest_multi_source(
    satellite={'bbox': [-122.5, 37.7, -122.3, 37.9]},
    sensors={'time_range': '2023-01-01/2023-01-31'},
    crowdsourced={'category': 'environment'}
)

IntelligentETLPipeline

Advanced ETL workflows with automatic dependency resolution.

from geo_infer_data import IntelligentETLPipeline

# Initialize ETL pipeline
pipeline = IntelligentETLPipeline(
    workflow_config='etl_config.yaml',
    dependency_resolution='automatic',
    error_recovery='intelligent_retry'
)

# Execute workflow
result = await pipeline.execute_workflow(
    source_data=raw_data,
    target_storage=processed_storage,
    transformation_rules=transformations
)

AdaptiveDataStorage

Multi-backend storage with automatic optimization.

from geo_infer_data import AdaptiveDataStorage

# Initialize adaptive storage
storage = AdaptiveDataStorage(
    storage_backends=['postgresql', 'minio', 'redis'],
    optimization_strategy='access_pattern_based',
    compression_enabled=True
)

# Store geospatial data
data_id = await storage.store_geospatial_data(
    data=geospatial_data,
    metadata=dataset_metadata,
    access_patterns=usage_patterns
)

# Retrieve data
data = await storage.retrieve_geospatial_data(
    data_id=data_id,
    format='geopandas'
)

DataQualityManager

Comprehensive data validation and quality assurance.

from geo_infer_data import DataQualityManager

# Initialize quality manager
quality_manager = DataQualityManager(
    validation_rules='strict',
    quality_metrics=['completeness', 'accuracy', 'consistency']
)

# Validate dataset
quality_report = quality_manager.validate_dataset(
    dataset=dataset,
    schema=schema_definition
)

# Assess quality
quality_score = quality_manager.assess_quality(quality_report)

DataAPI

RESTful API for data access and management.

from geo_infer_data.api import DataAPI

# Initialize data API
api = DataAPI(config='config/local.yaml')

# Start API server
api.start(host='0.0.0.0', port=8000)

Utility Functions

from geo_infer_data import (
    initialize_data_system,
    validate_data_integrity,
    optimize_storage_performance
)

# Initialize complete data system
system = initialize_data_system(
    config_path='config/data_config.yaml',
    storage_backends=['postgresql', 'minio'],
    enable_validation=True
)

# Validate data integrity
integrity_report = validate_data_integrity(
    dataset_ids=['dataset_1', 'dataset_2']
)

# Optimize storage
optimization_result = optimize_storage_performance(
    storage_backend='postgresql',
    optimization_target='query_performance'
)

Integration with Other Modules

GEO-INFER-DATA is central to the framework:

  • GEO-INFER-OPS (Operations): OPS may orchestrate ETL pipelines defined in DATA (e.g., using Airflow). DATA provides monitoring information about data quality and pipeline status to OPS.
  • GEO-INFER-SPACE (Spatial Methods) & GEO-INFER-TIME (Temporal Methods): These modules consume data prepared and served by DATA. They rely on DATA for efficient access to vector, raster, and time-series data for their analytical operations.
  • GEO-INFER-AI (Artificial Intelligence) & GEO-INFER-ACT (Active Inference): Training data for machine learning models and input data for active inference agents are sourced through DATA. DATA ensures this data is clean, well-structured, and versioned.
  • GEO-INFER-SEC (Security): DATA implements access control policies defined by SEC, ensuring that sensitive geospatial data is protected. Secure data handling protocols are enforced during ETL and storage.
  • GEO-INFER-API (Interfaces): The Data Access API component of DATA can be exposed or aggregated through the main GEO-INFER-API module for external consumption.
  • GEO-INFER-APP (Applications): User-facing applications query and visualize data made available through DATA's access layers.

Performance Considerations

Optimizing data operations is crucial. Key strategies include:

  • Efficient spatial and temporal indexing.
  • Use of optimized file formats (e.g., COG, Parquet).
  • Partitioning large datasets.
  • Parallel processing for ETL jobs.
  • Query optimization and caching. Refer to docs/PERFORMANCE_GUIDELINES.md for detailed guidance.

Data Governance

The module embodies strong data governance principles:

  • Data Lineage Tracking: Recording the origin, transformations, and movement of data throughout its lifecycle.
  • Comprehensive Metadata Management: Adhering to standards (ISO 19115, Dublin Core, STAC) for discoverability and understanding.
  • Quality Assurance Workflows: Automated checks and manual reviews to ensure data accuracy, completeness, and consistency.
  • Access Control & Privacy Preservation: Integration with GEO-INFER-SEC to enforce role-based access and apply anonymization/ pseudonymization techniques where needed.
  • Data Versioning & Audit Trails: Keeping track of changes to datasets and schema modifications.

Contributing

Core Features

1. Multi-Source Data Ingestion

Purpose: Ingest and process data from diverse geospatial sources with automatic format detection and validation.

from geo_infer_data.ingestion import MultiSourceDataIngestion

ingestion = MultiSourceDataIngestion(
    data_sources=['satellite', 'iot_sensors', 'weather_api', 'crowdsourced'],
    format_detection='automatic',
    validation_enabled=True,
    quality_threshold=0.8
)

# Ingest multi-source data
ingested_data = ingestion.ingest_multi_source(
    satellite_imagery=landsat_data,
    sensor_data=iot_measurements,
    weather_data=meteorological_api,
    crowdsourced_data=community_reports
)

# Validate and clean ingested data
validated_data = ingestion.validate_and_clean(ingested_data)
quality_report = ingestion.generate_quality_report(validated_data)

2. Intelligent ETL Pipeline Management

Purpose: Manage complex ETL workflows with automatic dependency resolution and error recovery.

from geo_infer_data.pipeline import IntelligentETLPipeline

pipeline = IntelligentETLPipeline(
    workflow_config='etl_config.yaml',
    dependency_resolution='automatic',
    error_recovery='intelligent_retry',
    monitoring_enabled=True
)

# Execute ETL workflow
pipeline_results = pipeline.execute_workflow(
    source_data=raw_datasets,
    target_storage=processed_storage,
    transformation_rules=spatial_transformations
)

# Monitor pipeline performance
performance_metrics = pipeline.get_performance_metrics()
bottlenecks = pipeline.identify_bottlenecks(performance_metrics)

3. Adaptive Data Storage and Querying

Purpose: Dynamically optimize data storage and querying based on access patterns and performance requirements.

from geo_infer_data.storage import AdaptiveDataStorage

storage = AdaptiveDataStorage(
    storage_backends=['postgresql', 'parquet', 'elasticsearch'],
    optimization_strategy='access_pattern_based',
    compression_enabled=True,
    indexing_strategy='spatial_temporal'
)

# Store geospatial data with automatic optimization
storage.store_geospatial_data(
    spatial_data=processed_datasets,
    metadata=dataset_metadata,
    access_patterns=expected_queries
)

# Query with adaptive optimization
query_results = storage.adaptive_query(
    spatial_bounds=query_region,
    temporal_range=time_window,
    optimization_hints={'frequent_queries': True}
)

API Reference

Core Classes

MultiSourceDataIngestion

  • ingest_multi_source(satellite, sensor, weather, crowdsourced): Ingest multi-source data
  • validate_and_clean(data): Validate and clean ingested data
  • generate_quality_report(data): Generate data quality report

IntelligentETLPipeline

  • execute_workflow(source, target, transformations): Execute ETL workflow
  • get_performance_metrics(): Get pipeline performance metrics
  • identify_bottlenecks(metrics): Identify performance bottlenecks

AdaptiveDataStorage

  • store_geospatial_data(data, metadata, patterns): Store geospatial data
  • adaptive_query(bounds, range, hints): Query with adaptive optimization
  • optimize_storage_for_patterns(patterns): Optimize storage for access patterns

REST API Endpoints

POST /api/v1/data/ingest/multi-source
GET  /api/v1/data/quality/{dataset_id}
POST /api/v1/data/etl/execute
GET  /api/v1/data/storage/{dataset_id}/query

Use Cases

Environmental Monitoring Data Pipeline

Scenario: Automated ingestion, processing, and storage of environmental monitoring data from multiple sources.

from geo_infer_data.environmental import EnvironmentalDataPipeline

env_pipeline = EnvironmentalDataPipeline(
    monitoring_stations=['air_quality', 'water_quality', 'weather'],
    data_sources=['sensors', 'satellite', 'crowdsourced'],
    processing_requirements=['quality_control', 'spatial_interpolation']
)

# Set up automated pipeline
env_pipeline.setup_automated_pipeline(
    ingestion_frequency='real_time',
    processing_triggers=['data_threshold', 'time_interval'],
    storage_optimization='spatial_temporal'
)

# Execute environmental data workflow
environmental_insights = env_pipeline.process_environmental_data(
    current_monitoring_data=latest_sensor_readings,
    historical_context=historical_environmental_data,
    analysis_requirements=['trend_analysis', 'anomaly_detection']
)

Urban Infrastructure Data Management

Scenario: Manage complex urban infrastructure data with real-time updates and spatial optimization.

from geo_infer_data.urban import UrbanInfrastructureDataManager

urban_manager = UrbanInfrastructureDataManager(
    infrastructure_types=['transportation', 'utilities', 'buildings'],
    data_sources=['sensors', 'maintenance_records', 'public_reports'],
    spatial_resolution='building_level'
)

# Manage urban infrastructure data lifecycle
urban_manager.manage_infrastructure_lifecycle(
    infrastructure_assets=city_infrastructure,
    maintenance_schedules=maintenance_calendar,
    public_reporting_enabled=True,
    real_time_monitoring=True
)

# Optimize urban data queries
optimized_queries = urban_manager.optimize_spatial_queries(
    query_patterns=urban_planning_queries,
    spatial_indexing='h3_adaptive',
    caching_strategy='intelligent'
)

Scientific Research Data Pipeline

Scenario: Support scientific research with comprehensive data management and analysis capabilities.

from geo_infer_data.research import ResearchDataPipeline

research_pipeline = ResearchDataPipeline(
    research_domains=['ecology', 'climate', 'urban_planning'],
    data_requirements=['high_precision', 'temporal_resolution', 'spatial_accuracy'],
    collaboration_features=['version_control', 'metadata_sharing']
)

# Set up research data pipeline
research_pipeline.setup_research_pipeline(
    research_team=collaborative_team,
    data_sharing_policies=research_collaboration_policy,
    quality_standards='scientific_grade'
)

# Process research data with analysis
research_results = research_pipeline.process_research_data(
    experimental_data=field_measurements,
    analysis_workflows=['statistical_modeling', 'spatial_analysis'],
    publication_requirements=['reproducible', 'citable']
)

Contributions are highly valued. Areas include:

  • Developing new ETL connectors for various data sources.
  • Improving data validation and quality assessment tools.
  • Optimizing storage and query performance for specific backends.
  • Enhancing metadata management capabilities.
  • Adding support for new geospatial data formats or standards.

Follow the contribution guidelines in the main GEO-INFER documentation (CONTRIBUTING.md) and any specific guidelines in GEO-INFER-DATA/docs/CONTRIBUTING_DATA.md (to be created).

License

This module is licensed under the Creative Commons Attribution-NoDerivatives-ShareAlike 4.0 International License (CC BY-ND-SA 4.0). Please see the LICENSE file in the root of the GEO-INFER repository for full details.