Modern GIS toolkit for Python - Simplifying geospatial workflows with built-in data sources, intelligent caching, and fluent APIs
# Clone the main repository
git clone https://github.com/pymapgis/core.git
cd core
# Or clone your fork
git clone https://github.com/yourusername/core.git
cd core
# Install Poetry (if not already installed)
curl -sSL https://install.python-poetry.org | python3 -
# Or using pip
pip install poetry
# Verify installation
poetry --version
# Install dependencies
poetry install
# Install with all optional dependencies
poetry install --extras "streaming pointcloud enterprise"
# Activate the virtual environment
poetry shell
# Test basic functionality
python -c "import pymapgis as pmg; print(pmg.__version__)"
# Run basic tests
poetry run pytest tests/test_settings.py -v
# Check CLI
poetry run pymapgis info
# Install pre-commit hooks
poetry run pre-commit install
# Run hooks manually
poetry run pre-commit run --all-files
# Format code with Black
poetry run black pymapgis/ tests/
# Lint with Ruff
poetry run ruff check pymapgis/ tests/
# Type checking with MyPy
poetry run mypy pymapgis/
# Run all tests
poetry run pytest
# Run with coverage
poetry run pytest --cov=pymapgis --cov-report=html
# Run specific test categories
poetry run pytest -m "not slow" # Skip slow tests
poetry run pytest -m integration # Only integration tests
Create .vscode/settings.json
:
{
"python.defaultInterpreterPath": ".venv/bin/python",
"python.formatting.provider": "black",
"python.linting.enabled": true,
"python.linting.ruffEnabled": true,
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": ["tests/"],
"files.exclude": {
"**/__pycache__": true,
"**/*.pyc": true,
".pytest_cache": true,
".coverage": true,
"htmlcov": true
}
}
Create .env
file in project root:
# PyMapGIS Settings
PYMAPGIS_CACHE_DIR=./cache
PYMAPGIS_DEFAULT_CRS=EPSG:4326
PYMAPGIS_LOG_LEVEL=DEBUG
# API Keys (optional)
CENSUS_API_KEY=your_census_api_key_here
# Development flags
PYMAPGIS_DEV_MODE=true
PYMAPGIS_ENABLE_PROFILING=false
Create .env.test
:
# Test-specific settings
PYMAPGIS_CACHE_DIR=./test_cache
PYMAPGIS_LOG_LEVEL=WARNING
PYMAPGIS_SKIP_SLOW_TESTS=true
# Dockerfile.dev
FROM python:3.11-slim
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Install Poetry
RUN pip install poetry
# Copy project files
COPY pyproject.toml poetry.lock ./
RUN poetry config virtualenvs.create false \
&& poetry install --no-dev
COPY . .
CMD ["bash"]
# docker-compose.dev.yml
version: '3.8'
services:
pymapgis-dev:
build:
context: .
dockerfile: Dockerfile.dev
volumes:
- .:/app
- /app/.venv
environment:
- PYMAPGIS_DEV_MODE=true
ports:
- "8000:8000"
command: bash
# Using Docker
docker run --name postgis \
-e POSTGRES_PASSWORD=password \
-e POSTGRES_DB=pymapgis_dev \
-p 5432:5432 \
-d postgis/postgis:latest
# Connection string
export DATABASE_URL="postgresql://postgres:password@localhost:5432/pymapgis_dev"
# Using Docker
docker run --name redis \
-p 6379:6379 \
-d redis:alpine
# Connection string
export REDIS_URL="redis://localhost:6379"
# All tests
poetry run pytest
# Specific test file
poetry run pytest tests/test_vector.py
# With coverage
poetry run pytest --cov=pymapgis
# Skip slow tests
poetry run pytest -m "not slow"
# Run in parallel
poetry run pytest -n auto
# Format code
poetry run black .
# Check formatting
poetry run black --check .
# Lint code
poetry run ruff check .
# Fix linting issues
poetry run ruff check --fix .
# Type checking
poetry run mypy pymapgis/
# Build documentation
cd docs
mkdocs serve
# Or using Poetry
poetry run mkdocs serve
# Profile a specific function
python -m cProfile -o profile.stats your_script.py
# Analyze profile
python -c "import pstats; pstats.Stats('profile.stats').sort_stats('cumulative').print_stats(20)"
# Clear Poetry cache
poetry cache clear --all pypi
# Reinstall dependencies
rm poetry.lock
poetry install
# Ensure you're in the Poetry environment
poetry shell
# Or run with Poetry
poetry run python your_script.py
# Clear test cache
rm -rf .pytest_cache
# Clear coverage data
rm .coverage
# Run tests with verbose output
poetry run pytest -v --tb=long
# Clear PyMapGIS cache
poetry run pymapgis cache clear
# Check cache statistics
poetry run pymapgis cache stats
import pymapgis as pmg
import logging
# Enable debug logging
logging.basicConfig(level=logging.DEBUG)
# Your code here
data = pmg.read("census://...")
import pymapgis as pmg
# Enable profiling
pmg.settings.enable_profiling = True
# Your code here
# Profiling data will be collected automatically
Next: Contributing Guide for contribution workflow and standards