Skip to main content

Manage your XYZ Hub server or HERE Data Hub from Python

Project description

XYZ Spaces for Python

Documentation Status Tests PyPI - Status PyPI - Python Version PyPI - Implementation Downloads Conda (channel only) Conda Downloads PyPI - License LGTM alerts LGTM context Swagger Validator GitHub contributors Codecov Slack Code style: black commits since Binder

Manage your XYZ Hub or HERE Data Hub spaces from Python.

FEATURED IN: Online Python Machine Learning Conference & GeoPython 2020, Sept 21, 2020, see conference schedule.

Motivation

XYZ is an Open Source, real-time, cloud database system providing access to large geospatial data at scale. An XYZ "Hub" manages "spaces" that contain "features" (geodata "records") with tags and properties, with spaces and features having unique IDs. A RESTful API exists to provide low-level access to interact with a XYZ Hub.

This Python package allows to interact with your XYZ spaces and features on a given Hub using a higher level programmatic interface that wraps the RESTful API. Using this package you can:

  • Create, read, list, update, share, delete spaces (also: get space info and stats).
  • Add, read, update, iterate, search, cluster (hex/quad bins), delete features.
  • Search features by ID, tag, property, bbox, tile, radius, geometry.

Based on the XYZ Hub the HERE Data Hub is a commercial service (with a free plan), that offers some additional features (in a pro plan), like clustering, virtual spaces, activity logs, and likely more to come.

The GIF below shows an interaction with an example notebook, demonstrating how to use a spatial search on a big public dataset, loaded from the HERE Data Hub.

Example from xyzspaces building_numbers.ipynb notebook

Prerequisites

Before you can install this package, run its test-suite or use the example notebooks to make sure your system meets the following prerequisities:

  • A Python installation, 3.6+ recommended, with the pip command available to install dependencies

  • A HERE developer account, free and available under HERE Developer Portal

  • An XYZ API access token from your XYZ Hub server or the XYZ portal (see also its Getting Started section) in an environment variable named XYZ_TOKEN which you can set like this (with a valid value, of course):

    export XYZ_TOKEN="MY-FANCY-XYZ-TOKEN"
    

    If you prefer, you can alternatively provide this token as a parameter in your code.

Installation

This package can be installed with pip or conda from various sources:

  • Install with conda from the Anaconda conda-forge channel:

    conda install -c conda-forge xyzspaces
    
  • Install from the Python Package Index:

    pip install xyzspaces
    
  • Install from its source repository on GitHub:

    pip install -e git+https://github.com/heremaps/xyz-spaces-python#egg=xyzspaces
    

If you want to run the test suite or experiment with the example notebooks bundled, you need to clone the whole repository:

  • Make a local clone of the repository hosting this package. The following command should do:

    git clone https://github.com/heremaps/xyz-spaces-python.git
    
  • Change into the repo root directory:

    cd xyzspaces
    

Documentation

Documentation is hosted here.

To build the docs locally run:

bash scripts/build_docs.sh

Hello World Example

The following is a tiny "Hello World"-like example that you can run to have a successful first XYZ experience right after installation! Just make sure to use your own real XYZ token!

import geojson
import xyzspaces

xyz = xyzspaces.XYZ(credentials="MY_XYZ_TOKEN")

# Create a New Space
title = "My Demo Space"
description = "My Description"
space = xyz.spaces.new(title=title, description=description)

# Define a New Feature
feature =  {
    "type": "Feature",
    "properties": {"party": "Republican"},
    "geometry": {
        "type": "Polygon",
        "coordinates": [[
            [-104.05, 48.99],
            [-97.22,  48.98],
            [-96.58,  45.94],
            [-104.03, 45.94],
            [-104.05, 48.99]
        ]]
    }
}

# Save it to a Space and get its ID
feature_id = space.add_features(features=geojson.FeatureCollection([feature]))["features"][0]["id"]

# Read a Feature from a Space
feature = space.get_feature(feature_id=feature_id)
print(geojson.dumps(feature, indent=4, sort_keys=True))

License

Copyright (C) 2019-2021 HERE Europe B.V.

Unless otherwise noted in LICENSE files for specific directories, the LICENSE in the root applies to all content in this repository.

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

xyzspaces-0.5.0.tar.gz (6.9 MB view details)

Uploaded Source

Built Distribution

xyzspaces-0.5.0-py2.py3-none-any.whl (150.7 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file xyzspaces-0.5.0.tar.gz.

File metadata

  • Download URL: xyzspaces-0.5.0.tar.gz
  • Upload date:
  • Size: 6.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

File hashes

Hashes for xyzspaces-0.5.0.tar.gz
Algorithm Hash digest
SHA256 d8ceaca8093440793c54e097a3adca828706aba91b6ab9b747313a0818fea422
MD5 f8097e9343bc11f63743bd96c70f74e6
BLAKE2b-256 f5033c2439e1aaa6b5ccda70d6e224aa91f172ea58e8aae7afdddaa30d848940

See more details on using hashes here.

File details

Details for the file xyzspaces-0.5.0-py2.py3-none-any.whl.

File metadata

  • Download URL: xyzspaces-0.5.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 150.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7

File hashes

Hashes for xyzspaces-0.5.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1283ed52c98c38e9809da5f0b10fcfb6309cc34851877bbec3490bf08be27f70
MD5 c3e111f7cf69756e9edbeb487f139335
BLAKE2b-256 3a8726f019e1d63a49ac5d4108d74242e9c73b3214c040e3fae89b7b2bcbb05f

See more details on using hashes here.

Supported by

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