Skip to main content

Client library for Geodata Pixel

Project description

Geodata Pixel Client

A Python client library for interacting with the Geodata Pixel API. Geodata Pixel is a SaaS solution for efficient image management, providing a centralized platform for uploading, storing, and structuring image data with geospatial information. This makes it easy to find and manage images based on time and location.

This client library provides a convenient interface for working with Geodata Pixel, allowing users to create projects, manage data collections, and upload and process various types of geospatial imagery including survey photos, drone imagery, 360° images, and raster data.

Geodata Pixel er vår løsning for effektiv bildeforvaltning. Med Geodata Pixel får du et felles sted å laste opp, lagre og strukturere bildedata, noe som gjør det enkelt å finne bilder basert på tid og sted.

Features

  • Dual API Support: Both synchronous and asynchronous interfaces
  • Data Management: Create and manage projects and data collections
  • Image Handling: Upload and process image data with geolocation
  • Raster Data Handling: Support for various raster data types (RGB, DTM, DSM)
  • ArcGIS Services: Create and manage ArcGIS Feature and Image services
  • Harvest Services: Automated data harvesting from ArcGIS Feature services
  • Authentication: Integrated Keycloak authentication
  • Metadata Management: Flexible metadata handling for uploaded files
  • Attachments: Add and manage file attachments to resources

Installation

Warning This package is not yet available on PyPI. You can install it from the source code repository instead.

pip install pixel-client

Requirements

  • Python 3.11 or higher

Authentication

The Pixel client requires authentication through Keycloak. You can provide authentication details through environment variables, a .env file, or directly in code:

from pixel_client import get_client, PixelApiSettings

# Using environment variables
client = get_client()

# Using direct settings
settings = PixelApiSettings(
    PIXEL_TENANT="your_realm",
    PIXEL_USERNAME="your_username",
    PIXEL_PASSWORD="your_password"
)
client = get_client(settings=settings)

# Using a .env file
settings = PixelApiSettings.from_env_file("my_env_file.env")
client = get_client(settings=settings)

Quick Start

Synchronous Usage

from pixel_client import get_client
from geojson_pydantic import Polygon

# Initialize the client
client = get_client()

# Create a project
new_project = client.create_project(
    name="My New Project",
    description="A test project",
    area_of_interest=Polygon.model_validate({
        "type": "Polygon",
        "coordinates": [[[-10, 10], [-10, 20], [0, 20], [0, 10], [-10, 10]]]
    }),
    tags=["test", "example"]
)

# Create a data collection
data_collection = client.create_data_collection(
    project_id=new_project["id"],
    name="My Data Collection",
    description="An example data collection",
    data_collection_type="image",
    tags=["example", "images"]
)

Asynchronous Usage

import asyncio
from pixel_client import get_client
from geojson_pydantic import Polygon

async def main():
    # Initialize the async client
    client = get_client(async_=True)
    
    # Create a project
    new_project = await client.create_project(
        name="My Async Project",
        description="A test async project",
        area_of_interest=Polygon.model_validate({
            "type": "Polygon",
            "coordinates": [[[-10, 10], [-10, 20], [0, 20], [0, 10], [-10, 10]]]
        }),
        tags=["test", "async"]
    )
    
    # Create a data collection
    data_collection = await client.create_data_collection(
        project_id=new_project["id"],
        name="My Async Data Collection",
        description="An example async data collection",
        data_collection_type="image",
        tags=["example", "async"]
    )

asyncio.run(main())

Uploading Data

Image Data

from pixel_client import get_client, PixelUploadFile, MetadataObject, ImageMetadataFields
from pathlib import Path

client = get_client()

# Upload images to a data collection
image_files = [
    PixelUploadFile(
        file=Path("path/to/image.jpg"),
        metadata=MetadataObject(
            fields=ImageMetadataFields(name="my_image"),
            json_metadata={"custom_field": "value"}
        )
    )
]

images, errors = client.upload_multiple_images(
    project_id=project_id,
    data_collection_id=data_collection_id,
    files=image_files
)

Raster Data

The client supports various raster data types:

  • raster: Generic raster data
  • RGB: RGB raster data (3 or 4 bands, uint8)
  • DTM: Digital Terrain Model data (single band, float32/float64)
  • DSM: Digital Surface Model data (single band, float32/float64)

Project Structure

The project is organized as follows:

  • src/: Source code for the Pixel client library
    • pixel_client/: Core client library code
      • __init__.py: Main entry point and exports
      • _base.py: Asynchronous client implementation
      • _sync.py: Synchronous client wrapper
      • auth.py: Authentication handling
      • models.py: Data models
      • settings.py: Configuration settings
      • exceptions.py: Custom exceptions
      • types.py: Type definitions
      • utils.py: Utility functions
  • docs/: Documentation
    • usage/: User guides and tutorials
    • api/: API reference documentation
    • assets/: Static assets for documentation
    • code_snippets/: Example code snippets
  • integration_tests/:
    • data: Sample data for integration tests
    • __init__.py: Initialization for integration tests
    • conftest.py: Configuration for pytest
    • constants.py: Constants used in tests
    • test_smoke.py: Smoketest for client functionality

Documentation

This project uses MkDocs with the Material theme for documentation. The documentation includes:

To build the documentation locally:

# Install dependencies with uv
uv sync --group docs --group dev

# Build and serve the documentation
uv run mkdocs serve

Development

Setting Up Development Environment

Requires uv package manager. To set up a development environment:

# Clone the repository
git clone "https://geonett@dev.azure.com/geonett/Geodata%20Pixel%20-%20Geodata%20Pixel/_git/pixel-client"
cd pixel-client

# Install development dependencies
uv sync --group dev

# Install documentation dependencies
uv sync --group docs --group dev

Pre-commit Hooks

This project uses pre-commit hooks to ensure code quality. To set up pre-commit:

pre-commit install

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

When contributing, please:

  1. Follow the existing code style
  2. Add tests for new functionality
  3. Update documentation as needed
  4. Run pre-commit hooks before submitting changes

License

See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pixel_client-1.2.7.tar.gz (39.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pixel_client-1.2.7-py3-none-any.whl (41.4 kB view details)

Uploaded Python 3

File details

Details for the file pixel_client-1.2.7.tar.gz.

File metadata

  • Download URL: pixel_client-1.2.7.tar.gz
  • Upload date:
  • Size: 39.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pixel_client-1.2.7.tar.gz
Algorithm Hash digest
SHA256 81ef0f64a7e5b452e23fd374568dca9ba05f9e10c390f8135f0d6eac38675194
MD5 a675a271a9e470b28331a82ad1abe25e
BLAKE2b-256 b91ff8a028ac7f769822c38e8b20b2a8df5eade05461c7a86dc473ec4f52ca7c

See more details on using hashes here.

File details

Details for the file pixel_client-1.2.7-py3-none-any.whl.

File metadata

  • Download URL: pixel_client-1.2.7-py3-none-any.whl
  • Upload date:
  • Size: 41.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pixel_client-1.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 4b48a32b308dffbea29f59dc15a5e915a9184647e06db2905f83e3f034ee567c
MD5 fcd041a37a4d7b2fde54fb5ee94f44db
BLAKE2b-256 89ac795931e0771a442318646863cffb88443afffd0e2e59f14be8c7bcb51156

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page