Skip to main content

Lightweight Python bindings for the TG geometry library

Reason this release was yanked:

Unstable?

Project description

ToGo

Python bindings for TG (Geometry library for C - Fast point-in-polygon)

ToGo is a high-performance Python library for computational geometry, providing a Cython wrapper around the above-mentioned C library.

The main goal is to offer a Pythonic, object-oriented, fast and memory-efficient library for geometric operations, including spatial predicates, format conversions, and spatial indexing.

While ToGo's API interfaces are still a work in progress, the underling C library is stable and well-tested.

Installation

pip install togo

Features

  • Fast and efficient geometric operations
  • Support for standard geometry types: Point, Line, Ring, Polygon, and their multi-variants
  • Geometric predicates: contains, intersects, covers, touches, etc.
  • Format conversion between WKT, GeoJSON, WKB, and HEX
  • Spatial indexing for accelerated queries
  • Memory-efficient C implementation with Python-friendly interface

Basic Usage

from togo import Geometry, Point, Ring, Poly

# Create a geometry from GeoJSON
geom = Geometry('{"type":"Point","coordinates":[1.0,2.0]}')

# Create a point
point = Point(1.0, 2.0)

# Create a polygon
ring = Ring([(0,0), (10,0), (10,10), (0,10), (0,0)])
polygon = Poly(ring)

# Convert to various formats
wkt = polygon.as_geometry().to_wkt()
geojson = polygon.as_geometry().to_geojson()

# Perform spatial predicates
point_geom = point.as_geometry()
contains = polygon.as_geometry().contains(point_geom)

Core Classes

Geometry

The base class that wraps tg_geom structures and provides core operations:

# Create from various formats
g1 = Geometry('POINT(1 2)', fmt='wkt')
g2 = Geometry('{"type":"Point","coordinates":[1,2]}', fmt='geojson')

# Geometric predicates
g1.intersects(g2)
g1.contains(g2)
g1.within(g2)

# Format conversion
g1.to_wkt()
g1.to_geojson()

# Access sub-geometries by index (e.g., for GeometryCollection, MultiPoint, etc.)
gc = Geometry('GEOMETRYCOLLECTION(POINT(1 2),POINT(3 4))', fmt='wkt')
first = gc[0]  # Bound to TG function call tg_geom_geometry_at(idx)
second = gc[1]
print(first.type_string())  # 'Point'

Point, Line, Ring, Poly

Building blocks for constructing geometries:

# Create a point
p = Point(1.0, 2.0)

# Create a line
line = Line([(0,0), (1,1), (2,2)])

# Create a ring (closed line)
ring = Ring([(0,0), (10,0), (10,10), (0,10), (0,0)])

# Create a polygon with holes
exterior = Ring([(0,0), (10,0), (10,10), (0,10), (0,0)])
hole = Ring([(2,2), (8,2), (8,8), (2,8), (2,2)])
poly = Poly(exterior, [hole])

MultiGeometries

Creating collections of geometries:

# Create a MultiPoint
multi_point = Geometry.from_multipoint([(0,0), (1,1), Point(2,2)])

# Create a MultiLineString
multi_line = Geometry.from_multilinestring([
    [(0,0), (1,1)],
    Line([(2,2), (3,3)])
])

# Create a MultiPolygon
poly1 = Poly(Ring([(0,0), (1,0), (1,1), (0,1), (0,0)]))
poly2 = Poly(Ring([(2,2), (3,2), (3,3), (2,3), (2,2)]))
multi_poly = Geometry.from_multipolygon([poly1, poly2])

Segment

Represents a line segment between two points:

from togo import Segment, Point

# Create a segment from two points (or tuples)
seg = Segment(Point(0, 0), Point(1, 1))
# Or using tuples
tuple_seg = Segment((0, 0), (1, 1))

# Access endpoints
print(seg.a)  # Point(0, 0)
print(seg.b)  # Point(1, 1)

# Get the bounding rectangle
rect = seg.rect()
print(rect)  # ((0.0, 0.0), (1.0, 1.0))

# Check intersection with another segment
other = Segment((1, 1), (2, 2))
print(seg.intersects(other))  # True or False

Polygon Indexing

Togo supports different polygon indexing strategies for optimized spatial operations:

from togo import TGIndex, set_polygon_indexing_mode

# Set the indexing mode
set_polygon_indexing_mode(TGIndex.NATURAL)  # or NONE, YSTRIPES

Performance Considerations

  • Togo is optimized for speed and memory efficiency
  • For large datasets, proper indexing can significantly improve performance
  • Creating geometries with the appropriate format avoids unnecessary conversions

Soon there will be a full API documentation, for now please refer to the test suite for more usage examples.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

togo-0.1.2-cp314-cp314t-musllinux_1_2_x86_64.whl (981.3 kB view details)

Uploaded CPython 3.14tmusllinux: musl 1.2+ x86-64

togo-0.1.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.14tmanylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

togo-0.1.2-cp314-cp314-musllinux_1_2_x86_64.whl (977.5 kB view details)

Uploaded CPython 3.14musllinux: musl 1.2+ x86-64

togo-0.1.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

togo-0.1.2-cp313-cp313-musllinux_1_2_x86_64.whl (983.8 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

togo-0.1.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

togo-0.1.2-cp312-cp312-musllinux_1_2_x86_64.whl (1.8 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

togo-0.1.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

togo-0.1.2-cp311-cp311-musllinux_1_2_x86_64.whl (989.4 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

togo-0.1.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

togo-0.1.2-cp310-cp310-musllinux_1_2_x86_64.whl (955.1 kB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

togo-0.1.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (979.9 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

togo-0.1.2-cp39-cp39-musllinux_1_2_x86_64.whl (953.1 kB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ x86-64

togo-0.1.2-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (977.9 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

togo-0.1.2-cp38-cp38-musllinux_1_2_x86_64.whl (975.0 kB view details)

Uploaded CPython 3.8musllinux: musl 1.2+ x86-64

togo-0.1.2-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file togo-0.1.2-cp314-cp314t-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for togo-0.1.2-cp314-cp314t-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b2a5c20bfddcec8918738ac33b92b6520be10dcc5ae4c6051bfec0efc71723c2
MD5 03e5b03ba6e365f943a9dda15e785e1a
BLAKE2b-256 62120b2d1624faf75f7a5b5ab850d531c80a968a25004496738670ef990c9df8

See more details on using hashes here.

Provenance

The following attestation bundles were made for togo-0.1.2-cp314-cp314t-musllinux_1_2_x86_64.whl:

Publisher: build-wheels.yml on mindflayer/togo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file togo-0.1.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for togo-0.1.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3acf32f4f8af04723c0d7f777602cc1c785f2a3d40e142420feab1c1f770f794
MD5 2b9bf4f4950d7c23e977aad215b18f0d
BLAKE2b-256 d7fb8624ff69d228748f52f1a2106ce742f37c570c012af10358c2f177ffc3dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for togo-0.1.2-cp314-cp314t-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on mindflayer/togo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file togo-0.1.2-cp314-cp314-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for togo-0.1.2-cp314-cp314-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 13585cc1c21b7edb0dc84c7df858e3f00d730e0905271884dd9110b6a91d472e
MD5 2e977167e69e880836213c24f5dd0661
BLAKE2b-256 4d82d6fe59f7e8de082a00b73d1d5b121e6815195091c1e60d8b9c4db63cbf46

See more details on using hashes here.

Provenance

The following attestation bundles were made for togo-0.1.2-cp314-cp314-musllinux_1_2_x86_64.whl:

Publisher: build-wheels.yml on mindflayer/togo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file togo-0.1.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for togo-0.1.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6f8474fc926ff1f5435e300097170e2c5984c40e9db21820f82c8e90327c219c
MD5 9aef8b15babb3bb83777a0a2ee4f95c3
BLAKE2b-256 6d0bf0bb0ecc440def24893a393bf061595755d07f1acbe1b27f670dbfadb656

See more details on using hashes here.

Provenance

The following attestation bundles were made for togo-0.1.2-cp314-cp314-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on mindflayer/togo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file togo-0.1.2-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for togo-0.1.2-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2615c6fd91ca356309baa479a0c06ed39ce637b69453b9f59beb2dfef7901d6f
MD5 7e4642a3f713df04c0139aa2a637b8ed
BLAKE2b-256 b6199e9416e81e552f2e548901045dac98b4a85f194b75b62cea28a60ab64a62

See more details on using hashes here.

Provenance

The following attestation bundles were made for togo-0.1.2-cp313-cp313-musllinux_1_2_x86_64.whl:

Publisher: build-wheels.yml on mindflayer/togo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file togo-0.1.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for togo-0.1.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3f976ffc991eecb321aade2a137b709fc97d3926a27711bed72c9e9fc199a936
MD5 27e797b8511eccf5a82065f8f5c1d982
BLAKE2b-256 a027f3a3a42ffdcc2d289448a77d6d07d206c25bd2bc7242cf4a81b0a78ad5c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for togo-0.1.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on mindflayer/togo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file togo-0.1.2-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for togo-0.1.2-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9cca4c2998791e499f56ada01ea6578717f907415a86b6091fbafb83d1cda900
MD5 19d715c1d53271cffbeb102a6a2890b6
BLAKE2b-256 a4cc383a2ff2985c8470d8aeb31bc37613803223825d21c221614fa308204caf

See more details on using hashes here.

Provenance

The following attestation bundles were made for togo-0.1.2-cp312-cp312-musllinux_1_2_x86_64.whl:

Publisher: build-wheels.yml on mindflayer/togo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file togo-0.1.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for togo-0.1.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 92f9399a94eb84c28b6f42febfd080778cbdb9c00c11a40fbacd2d375c30b0a7
MD5 6214f8fd1fec3e6614048d2e2a473540
BLAKE2b-256 1dedc86e364aa8f2234a651c85e59dbd43e8495b82bbe4e9d5615c72810f6645

See more details on using hashes here.

Provenance

The following attestation bundles were made for togo-0.1.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on mindflayer/togo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file togo-0.1.2-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for togo-0.1.2-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 852e7094bee26603e5013fc1509bfb05c12f3d8d2d53dad3f52fbaef73c7462d
MD5 d92644322989298978019cc100e7ce2d
BLAKE2b-256 441cd5aa067329c32847ab99ec6b12764b30e6ca9d656fceb017710bba93c5c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for togo-0.1.2-cp311-cp311-musllinux_1_2_x86_64.whl:

Publisher: build-wheels.yml on mindflayer/togo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file togo-0.1.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for togo-0.1.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5ab0894cf07d67c2c00cae391d8cdcf315b36c5c86cc1c5bc5d7af9bc50baf88
MD5 d1ee48de152fbe7fcc477958aaec2263
BLAKE2b-256 9bcdbe483572272e4bf8580b0547822c224ac339724d3a6ba53029492efd32a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for togo-0.1.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on mindflayer/togo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file togo-0.1.2-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for togo-0.1.2-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9cf6626480168ec1ff5cdeaca77cd150b4e0593fee3126ac952d5de9fdc49931
MD5 58b2c1293551090c37f6612f1daf33cc
BLAKE2b-256 451bfd57753fc69950883c5097cf61a159b379a684c9f51b728282310f9600e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for togo-0.1.2-cp310-cp310-musllinux_1_2_x86_64.whl:

Publisher: build-wheels.yml on mindflayer/togo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file togo-0.1.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for togo-0.1.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 03d9f379ac8f32ec2c864bf6ef9f25c7406a4b6f4bb91ec90980ad78803fe352
MD5 fd2e97858da52c48cdb7ff52e80b14d1
BLAKE2b-256 78e1b5c147fe53dd8684009e011772acb22ba7278377d8e3d64fdb2a721be4a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for togo-0.1.2-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on mindflayer/togo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file togo-0.1.2-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

  • Download URL: togo-0.1.2-cp39-cp39-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 953.1 kB
  • Tags: CPython 3.9, musllinux: musl 1.2+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for togo-0.1.2-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 47f13fd394884580a12c2a815eeeae028183eb5578051614f21ddb438a28fceb
MD5 fec0c7bd4466b127fc38b3b2587e2de3
BLAKE2b-256 43561a6548a2e6c3d677e9d36544cc5ca6d1dd98037e2f1418ed6ddcbced69cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for togo-0.1.2-cp39-cp39-musllinux_1_2_x86_64.whl:

Publisher: build-wheels.yml on mindflayer/togo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file togo-0.1.2-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for togo-0.1.2-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 84089ce0178efb302777def30bae27ab673f74b30de39496ae7e553b09c28a95
MD5 365b7d01c308780c07ae382ffd747d9d
BLAKE2b-256 26afd92295b37489e73f388a53ca27f92d1973283aea8e264b6d8491e41fd527

See more details on using hashes here.

Provenance

The following attestation bundles were made for togo-0.1.2-cp39-cp39-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on mindflayer/togo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file togo-0.1.2-cp38-cp38-musllinux_1_2_x86_64.whl.

File metadata

  • Download URL: togo-0.1.2-cp38-cp38-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 975.0 kB
  • Tags: CPython 3.8, musllinux: musl 1.2+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for togo-0.1.2-cp38-cp38-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1d105a9a5cdb585efeeb2ac0d071d6a10f0e76d8725ddaa0d762167839070522
MD5 64129846af89bd26eaac285bd745462f
BLAKE2b-256 548f78a5a7b90ffc47a04df2fccb0eff35660fe67f934bb95f746dc267b6364b

See more details on using hashes here.

Provenance

The following attestation bundles were made for togo-0.1.2-cp38-cp38-musllinux_1_2_x86_64.whl:

Publisher: build-wheels.yml on mindflayer/togo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file togo-0.1.2-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for togo-0.1.2-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e390e9073911a5a65902760f1d3c29de46e6df5dad995791218e2c4d438e4d5b
MD5 62a479e80dcf156f1d1be91328595e5a
BLAKE2b-256 7259d3a7c3fb2ba84f20043af2158ad9ed0dc147d976684ea7a137775ce2af2f

See more details on using hashes here.

Provenance

The following attestation bundles were made for togo-0.1.2-cp38-cp38-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheels.yml on mindflayer/togo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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