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, or long lived api keys
- Access Management: Manage users, groups, project access, api keys, and geo service users for ArcGIS services
- 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 authenticates either with Keycloak user credentials or with a Pixel api key. Provide exactly one of the two, through environment variables, a .env file, or directly in code:
from pixel_client import get_client, PixelApiSettings
# Using environment variables
client = get_client()
# Using Keycloak credentials
settings = PixelApiSettings(
PIXEL_TENANT="your_realm",
PIXEL_USERNAME="your_username",
PIXEL_PASSWORD="your_password"
)
client = get_client(settings=settings)
# Using an api key, for unattended access (CI jobs, scheduled scripts)
settings = PixelApiSettings(
PIXEL_TENANT="your_realm",
PIXEL_API_KEY="pixel_v1_..."
)
client = get_client(settings=settings)
# Using a .env file
settings = PixelApiSettings.from_env_file("my_env_file.env")
client = get_client(settings=settings)
Create api keys with create_api_key. The token is returned exactly once, at
creation, and is never retrievable again. An api key acts on behalf of the user
who created it, with the project roles, groups or organisation-wide role it was
given, and never more than that user's own current access.
Some management calls need a signed-in user and do not work with an api key:
creating, listing, renaming, revoking and replacing api keys, creating and
editing users, creating and changing geo service users, me, and the access
views (list_grants, get_user_access, get_group_access).
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 dataRGB: 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 librarypixel_client/: Core client library code__init__.py: Main entry point and exports_base.py: Asynchronous client implementation_sync.py: Synchronous client wrapperauth.py: Authentication handlingmodels.py: Data modelssettings.py: Configuration settingsexceptions.py: Custom exceptionstypes.py: Type definitionsutils.py: Utility functions
docs/: Documentationusage/: User guides and tutorialsapi/: API reference documentationassets/: Static assets for documentationcode_snippets/: Example code snippets
integration_tests/:data: Sample data for integration tests__init__.py: Initialization for integration testsconftest.py: Configuration for pytestconstants.py: Constants used in teststest_smoke.py: Smoketest for client functionality
Documentation
This project uses MkDocs with the Material theme for documentation. The documentation includes:
- Installation: How to install the library
- Getting Started: Getting started with the library
- Examples: Code examples for common tasks
- API Reference: Detailed API documentation
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:
- Follow the existing code style
- Add tests for new functionality
- Update documentation as needed
- Run pre-commit hooks before submitting changes
License
See LICENSE for details.
Metadata
Release files for pixel-client 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pixel_client-1.3.0.tar.gz | 62.6 kB | Without provenance | Details for pixel_client-1.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pixel_client-1.3.0-py3-none-any.whl | Python 3 | none | any | Details for pixel_client-1.3.0-py3-none-any.whl |
Total release size: 128.3 kB
Release files / pixel_client-1.3.0.tar.gz
| Download URL | pixel_client-1.3.0.tar.gz |
|---|---|
| Size | 62.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1da131b72a670c43967522f1ece2ff1ce651f4066133ee2d00b95a62a52352f8
|
|
BLAKE2b-256 checksum How to use checksums |
c2d0efc0795d7ffc7f9c9f9f138559dda6ff9a0c3058f6479ca586b794e3065d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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}
|
Release files / pixel_client-1.3.0-py3-none-any.whl
| Download URL | pixel_client-1.3.0-py3-none-any.whl |
|---|---|
| Size | 65.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a751a313e5fde2af7a53528294865c9c4a42fa0327c813a5e5fc3d62f2a68e09
|
|
BLAKE2b-256 checksum How to use checksums |
1cd23fc44a367635f8f13dde75b4faae1d640dcacf7317e851cf4e02559e8324
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","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}
|
Security for pixel-client 1.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.