Modern GIS toolkit for Python - Simplifying geospatial workflows with built-in data sources, intelligent caching, and fluent APIs
This document provides a detailed breakdown of PyMapGISβs package structure, explaining the purpose and contents of each module, submodule, and key files.
pymapgis/
βββ __init__.py # Main API surface and lazy imports
βββ settings.py # Global settings and configuration
βββ cache.py # Legacy cache utilities
βββ plotting.py # Legacy plotting functions
βββ acs.py # American Community Survey utilities
βββ tiger.py # TIGER/Line data utilities
βββ cli.py # Legacy CLI entry point
βββ serve.py # Legacy serve functionality
βββ [modules]/ # Core module directories
pymapgis/io/
)Purpose: Universal data reading and format handling
io/
βββ __init__.py # Main read() function and registry
βββ base.py # Base classes and interfaces
βββ registry.py # Data source plugin registry
βββ formats/ # Format-specific handlers
β βββ __init__.py
β βββ geojson.py # GeoJSON format handler
β βββ shapefile.py # Shapefile format handler
β βββ geopackage.py # GeoPackage format handler
β βββ raster.py # Raster format handlers
βββ sources/ # Data source implementations
β βββ __init__.py
β βββ census.py # Census API integration
β βββ tiger.py # TIGER/Line data source
β βββ file.py # Local file data source
β βββ http.py # HTTP/URL data source
β βββ cloud.py # Cloud storage data sources
βββ utils.py # IO utility functions
Key Components:
read()
- Main entry point for data readingDataSourceRegistry
- Plugin management systemDataSourcePlugin
- Base class for custom sourcespymapgis/vector/
)Purpose: Vector spatial operations and GeoPandas integration
vector/
βββ __init__.py # Core vector operations
βββ operations.py # Spatial operation implementations
βββ accessors.py # GeoDataFrame accessor methods
βββ geoarrow_utils.py # GeoArrow integration utilities
βββ spatial_index.py # Spatial indexing optimizations
βββ utils.py # Vector utility functions
Key Components:
clip()
, buffer()
, overlay()
, spatial_join()
- Core operations.pmg
accessor for GeoDataFramespymapgis/raster/
)Purpose: Raster processing and xarray integration
raster/
βββ __init__.py # Core raster operations
βββ operations.py # Raster operation implementations
βββ accessors.py # DataArray accessor methods
βββ cog.py # Cloud Optimized GeoTIFF utilities
βββ zarr_utils.py # Zarr format utilities
βββ reprojection.py # Coordinate system transformations
βββ utils.py # Raster utility functions
Key Components:
reproject()
, normalized_difference()
- Core operations.pmg
accessor for DataArrayspymapgis/viz/
)Purpose: Interactive mapping and visualization
viz/
βββ __init__.py # Main visualization functions
βββ accessors.py # Accessor methods for mapping
βββ leafmap_integration.py # Leafmap backend integration
βββ styling.py # Styling and symbology
βββ exports.py # Export functionality
βββ utils.py # Visualization utilities
Key Components:
.map()
and .explore()
accessor methodspymapgis/serve/
)Purpose: Web services and tile serving
serve/
βββ __init__.py # Main serve() function
βββ app.py # FastAPI application factory
βββ tiles/ # Tile generation
β βββ __init__.py
β βββ xyz.py # XYZ tile service
β βββ wms.py # WMS service
β βββ mvt.py # Vector tile (MVT) service
βββ middleware.py # Custom middleware
βββ auth.py # Service authentication
βββ utils.py # Service utilities
Key Components:
serve()
function as main entry pointpymapgis/cli/
)Purpose: Command-line interface
cli/
βββ __init__.py # CLI app and imports
βββ main.py # Main Typer application
βββ commands/ # Command implementations
β βββ __init__.py
β βββ info.py # System information commands
β βββ cache.py # Cache management commands
β βββ rio.py # Rasterio CLI passthrough
β βββ serve.py # Service commands
βββ utils.py # CLI utilities
Key Components:
pymapgis info
, pymapgis cache
, pymapgis rio
commandspymapgis/auth/
)Purpose: Enterprise authentication and security
auth/
βββ __init__.py # Main auth exports
βββ api_keys.py # API key management
βββ oauth.py # OAuth providers
βββ rbac.py # Role-based access control
βββ sessions.py # Session management
βββ security.py # Security utilities
βββ middleware.py # Authentication middleware
βββ providers/ # OAuth provider implementations
βββ __init__.py
βββ google.py # Google OAuth
βββ microsoft.py # Microsoft OAuth
βββ github.py # GitHub OAuth
pymapgis/cloud/
)Purpose: Cloud storage and processing integration
cloud/
βββ __init__.py # Main cloud functions
βββ storage.py # Cloud storage abstraction
βββ providers/ # Cloud provider implementations
β βββ __init__.py
β βββ aws.py # AWS S3 integration
β βββ gcp.py # Google Cloud Storage
β βββ azure.py # Azure Blob Storage
βββ processing.py # Cloud processing utilities
βββ utils.py # Cloud utilities
pymapgis/streaming/
)Purpose: Real-time data processing
streaming/
βββ __init__.py # Main streaming exports
βββ kafka_integration.py # Apache Kafka integration
βββ mqtt_integration.py # MQTT integration
βββ processors.py # Stream processing utilities
βββ buffers.py # Data buffering strategies
βββ utils.py # Streaming utilities
pymapgis/ml/
)Purpose: Spatial ML and analytics
ml/
βββ __init__.py # Main ML exports
βββ features.py # Spatial feature engineering
βββ sklearn_integration.py # Scikit-learn integration
βββ spatial_algorithms.py # Spatial ML algorithms
βββ evaluation.py # Model evaluation
βββ preprocessing.py # Data preprocessing
βββ pipelines.py # ML pipeline utilities
pymapgis/network/
)Purpose: Network analysis and routing
network/
βββ __init__.py # Main network exports
βββ graph.py # Graph construction
βββ routing.py # Routing algorithms
βββ analysis.py # Network analysis
βββ osm_integration.py # OpenStreetMap integration
βββ utils.py # Network utilities
pymapgis/pointcloud/
)Purpose: 3D point cloud processing
pointcloud/
βββ __init__.py # Main point cloud exports
βββ pdal_integration.py # PDAL integration
βββ processing.py # Point cloud processing
βββ visualization.py # 3D visualization
βββ formats.py # Format handling (LAS, LAZ, etc.)
βββ utils.py # Point cloud utilities
pymapgis/cache/
)Purpose: Intelligent caching system
cache/
βββ __init__.py # Main cache functions
βββ manager.py # Cache management
βββ backends/ # Cache backend implementations
β βββ __init__.py
β βββ memory.py # In-memory caching
β βββ disk.py # Disk-based caching
β βββ redis.py # Redis caching
βββ strategies.py # Caching strategies
βββ utils.py # Cache utilities
pymapgis/settings/
)Purpose: Configuration management
settings/
βββ __init__.py # Settings exports
βββ config.py # Configuration classes
βββ validation.py # Settings validation
βββ defaults.py # Default configurations
βββ utils.py # Settings utilities
pymapgis/plugins/
)Purpose: Plugin system and extensions
plugins/
βββ __init__.py # Plugin system exports
βββ registry.py # Plugin registry
βββ base.py # Base plugin classes
βββ loader.py # Plugin loading utilities
βββ discovery.py # Plugin discovery
βββ examples/ # Example plugins
βββ __init__.py
βββ sample_plugin.py # Sample plugin implementation
pymapgis/deployment/
)Purpose: Deployment utilities and configurations
deployment/
βββ __init__.py # Deployment exports
βββ docker.py # Docker utilities
βββ kubernetes.py # Kubernetes configurations
βββ cloud_deploy.py # Cloud deployment
βββ monitoring.py # Monitoring setup
βββ utils.py # Deployment utilities
pymapgis/testing/
)Purpose: Testing utilities and fixtures
testing/
βββ __init__.py # Testing exports
βββ fixtures.py # Common test fixtures
βββ data.py # Test data generation
βββ mocks.py # Mock objects
βββ assertions.py # Custom assertions
βββ utils.py # Testing utilities
pymapgis/performance/
)Purpose: Performance optimization and profiling
performance/
βββ __init__.py # Performance exports
βββ profiling.py # Profiling utilities
βββ optimization.py # Optimization strategies
βββ benchmarks.py # Benchmark utilities
βββ monitoring.py # Performance monitoring
βββ utils.py # Performance utilities
__init__.py
- Module exports and main APIbase.py
- Base classes and interfacesutils.py
- Utility functionsexceptions.py
- Custom exceptions{feature}.py
- Main feature implementation{feature}_integration.py
- Third-party integrations{feature}_utils.py
- Feature-specific utilitiestest_{module}.py
- Module teststest_{feature}.py
- Feature testsconftest.py
- pytest configuration__init__.py
_
Next: Design Patterns for architectural patterns used throughout PyMapGIS