Skip to main content

# SpatialIndex

## Spatial Indexing Library for Astronomy

One of the most common database searches in astronomy involves finding all the objects in a region of the sky. Basic DBMS engines provide efficient indexed searches only for single column (i.e. something that can be sorted linearly). Some servers are starting to support true multidimensional indexing (e.g., R-Trees) but this is neither universal nor uniform.

It is, however, possible to leverage the standard internal database indexing (B-Tree) to support impressively efficient 2D indexing. If one tesselates the sky into a hierarchical, Z-ordered space (using a scheme like a Heirarchical Triangular Mesh (HTM) or Hierarchical Equal Area isoLatitude Pixelization (HEALPix)), then any “object” (sky coordinate) belongs to a specific tesselation cell and each cell has a unique ID (number). This number can be stored in an integer column in the database table.

Then when one wants to perform a spatial search, the region can be converted to a range (actually set of ranges) of spatial index cell numbers and (because of the Z-ordering) these ranges tend to be co-located and can be accessed efficiently. For large tables, this can speed up queries by orders of magnitude.

To perform a spatial search, the region can be converted to a range of spatial index cell numbers and, because of the Z-ordering, these ranges tend to be co-located and can therefore accessed efficiently. For large tables, this can speed up queries by orders of magnitude. The resultant records are actually a superset of those desired, but a simple geometric filtering, performed as part of the database query, removes the extraneous records.

The spatal searches require that the DBMS table be augmented with four extra columns: a spatial index column at some pre-chosen HTM/HEALPix level and the three-vector (x,y,z) coordinate of the point on the sky.

Our library converts a geometric constraint into a pair of constraints that can be added to SQL to turn it into a spatially-indexed region query. For instance, if the DBMS table has been indexed at HTM level 7, a cone on the sky at latitude 43.7, longitude 129.4 with radius 0.5 degrees gets turned into the following SQL constraints

> WHERE ( (htm7 = 245093) > OR (htm7 = 245098) > OR (htm7 = 245100) > OR (htm7 = 245105) > OR (htm7 = 245110) > OR (htm7 = 245118)) > > AND (-0.45888930755155893*x)+(0.55866098617988125*y)+(0.69088241107685844*z) > >=9.99975630705394747e-01

These constraints are inserted into the SQL statement submitted to the DBMS.

Building the Python library:

The C spatial index code needs to be wrapped for Python use. This is taken care of in the Makefile and consists of using Cython to compile the spatial-index.pyx code (Python with Cython directives) into “spatial_index.c”, then building a LINUX library from the result plus our C libraries (our C code plus tinyhtm). This results in a library file “spatial_index.cpython-37m-x86_64-linux-gnu.so” which has the right content to be loadable by the Python runtime and accessed by Python calls.

The last step is to turn this into a Wheel file that can be pip-install in our Python distribution and/or uploaded to PyPI. This file is (dist/spatial_index-0.9-cp37-cp37m-linux_x86_64.whl). There is bookkeepping as well, but the primary files in this sequence are again

spatial_index.c spatial_index.cpython-37m-x86_64-linux-gnu.so dist/spatial_index-0.9-cp37-cp37m-linux_x86_64.whl

The NASA Exoplanet Science Institute is operated by the California Institute of Technology, under contract with the National Aeronautics and Space Administration under the Exoplanet Exploration Program.

Metadata

Release files for spatial-index 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for spatial-index 1.1.0
File Actions
spatial_index-1.1.0-cp38-cp38-manylinux2010_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.12+ x86-64 Details for spatial_index-1.1.0-cp38-cp38-manylinux2010_x86_64.whl
spatial_index-1.1.0-cp38-cp38-manylinux1_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.5+ x86-64 Details for spatial_index-1.1.0-cp38-cp38-manylinux1_x86_64.whl
spatial_index-1.1.0-cp38-cp38-macosx_10_9_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.9+ x86-64 Details for spatial_index-1.1.0-cp38-cp38-macosx_10_9_x86_64.whl
spatial_index-1.1.0-cp37-cp37m-manylinux2010_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64 Details for spatial_index-1.1.0-cp37-cp37m-manylinux2010_x86_64.whl
spatial_index-1.1.0-cp37-cp37m-manylinux1_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 Details for spatial_index-1.1.0-cp37-cp37m-manylinux1_x86_64.whl
spatial_index-1.1.0-cp37-cp37m-macosx_10_7_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.7+ x86-64 Details for spatial_index-1.1.0-cp37-cp37m-macosx_10_7_x86_64.whl
spatial_index-1.1.0-cp36-cp36m-manylinux2010_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-64 Details for spatial_index-1.1.0-cp36-cp36m-manylinux2010_x86_64.whl
spatial_index-1.1.0-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details for spatial_index-1.1.0-cp36-cp36m-manylinux1_x86_64.whl
spatial_index-1.1.0-cp36-cp36m-macosx_10_6_intel.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386) Details for spatial_index-1.1.0-cp36-cp36m-macosx_10_6_intel.whl
spatial_index-1.1.0-cp27-cp27m-manylinux2010_x86_64.whl CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.12+ x86-64 Details for spatial_index-1.1.0-cp27-cp27m-manylinux2010_x86_64.whl
spatial_index-1.1.0-cp27-cp27m-manylinux1_x86_64.whl CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.5+ x86-64 Details for spatial_index-1.1.0-cp27-cp27m-manylinux1_x86_64.whl
spatial_index-1.1.0-cp27-cp27m-macosx_10_6_x86_64.whl CPython 2.7 CPython 2.7 pymalloc macOS 10.6+ x86-64 Details for spatial_index-1.1.0-cp27-cp27m-macosx_10_6_x86_64.whl

Total release size: 1.8 MB

Release files / spatial_index-1.1.0-cp38-cp38-manylinux2010_x86_64.whl

Download URL spatial_index-1.1.0-cp38-cp38-manylinux2010_x86_64.whl
Size 213.1 kB
Tags CPython 3.8 Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
9aa327b7fb4e5d956ca20a258bb8b951a5df7f0959e0a6afd786bc48214d715f
BLAKE2b-256 checksum
How to use checksums
a6941612a1da27f9bf826d14392c3815709e579f76b42cf6b4c8a1f56d36f2ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release files / spatial_index-1.1.0-cp38-cp38-manylinux1_x86_64.whl

Download URL spatial_index-1.1.0-cp38-cp38-manylinux1_x86_64.whl
Size 213.1 kB
Tags CPython 3.8 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
ea3e76cb689424c126e5b4dbb801b94405e5fd7617461f499cebbb68be81d800
BLAKE2b-256 checksum
How to use checksums
579bd6ab60ee0459def8225a82cc8d54f30a7684a4931e552f09678e72663107
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release files / spatial_index-1.1.0-cp38-cp38-macosx_10_9_x86_64.whl

Download URL spatial_index-1.1.0-cp38-cp38-macosx_10_9_x86_64.whl
Size 69.8 kB
Tags CPython 3.8 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
ad28b2de7f0a0b06a06b8dc24e8408b5f0e977c396a28290bf2455cc87179368
BLAKE2b-256 checksum
How to use checksums
901f7e5bc70ae9b767575a34c9b875feb224c9baf7fa6045dc8dfce474290530
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release files / spatial_index-1.1.0-cp37-cp37m-manylinux2010_x86_64.whl

Download URL spatial_index-1.1.0-cp37-cp37m-manylinux2010_x86_64.whl
Size 187.7 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
f1c118782e0e16aa366ac5cf9bb5753590a7e36e26a4f0c05521e412a293d8a0
BLAKE2b-256 checksum
How to use checksums
dfea618b0e1c4d1f15c68757adf9c5cf9a4a8b58aee1b017027ea159b12b8c33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release files / spatial_index-1.1.0-cp37-cp37m-manylinux1_x86_64.whl

Download URL spatial_index-1.1.0-cp37-cp37m-manylinux1_x86_64.whl
Size 187.7 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
c5e29f476f8939ea053daacd381636ebaf8aae75e30521f256645dc840da5b8d
BLAKE2b-256 checksum
How to use checksums
288f2867370c9cbcb92af6b213501b797d0077cf5c5d11930530630bdb2c821e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release files / spatial_index-1.1.0-cp37-cp37m-macosx_10_7_x86_64.whl

Download URL spatial_index-1.1.0-cp37-cp37m-macosx_10_7_x86_64.whl
Size 69.5 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
c6832690fb413fa0e92c127ae191f77ecbabee99420d3947a4d637fe760446e9
BLAKE2b-256 checksum
How to use checksums
8876a0a33938b8ea74ac55e263a1019ba1cdd833b1873f6b1d021b5b383093c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release files / spatial_index-1.1.0-cp36-cp36m-manylinux2010_x86_64.whl

Download URL spatial_index-1.1.0-cp36-cp36m-manylinux2010_x86_64.whl
Size 185.7 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
52f630f830a7f084155ff5a57798d653f06b8d9f56d3e056e126e10555b2e48d
BLAKE2b-256 checksum
How to use checksums
bf5d7b2b65de018edfeef6ea3d39538b2055128cf1daab8678d549c39b61b6be
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release files / spatial_index-1.1.0-cp36-cp36m-manylinux1_x86_64.whl

Download URL spatial_index-1.1.0-cp36-cp36m-manylinux1_x86_64.whl
Size 185.7 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
2a8d24660748232378d8ad22144fcbe8a7d95cc697639554b166189b2341708a
BLAKE2b-256 checksum
How to use checksums
cf12131a3e81c376b1faecdccee154217fe3faef9cd6d8f0b6ad6bd0e577416f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release files / spatial_index-1.1.0-cp36-cp36m-macosx_10_6_intel.whl

Download URL spatial_index-1.1.0-cp36-cp36m-macosx_10_6_intel.whl
Size 95.1 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
b042c1dd9240740e4dfc07d6a96799d200656400f9ccad202d5824e9845fe000
BLAKE2b-256 checksum
How to use checksums
51318d34d813273ddde62c46946a8fb7630ca29e285ee199bd6990b55643321f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release files / spatial_index-1.1.0-cp27-cp27m-manylinux2010_x86_64.whl

Download URL spatial_index-1.1.0-cp27-cp27m-manylinux2010_x86_64.whl
Size 177.9 kB
Tags CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
10e88066979dc127c408f26a0f7c50c7403d03fad188adb9284529ce0ade6ed3
BLAKE2b-256 checksum
How to use checksums
c48f4eb05b8deecf19962f536eab983a23b11ddd346875b163b76b0e63e6fcbc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release files / spatial_index-1.1.0-cp27-cp27m-manylinux1_x86_64.whl

Download URL spatial_index-1.1.0-cp27-cp27m-manylinux1_x86_64.whl
Size 177.9 kB
Tags CPython 2.7 CPython 2.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
4ca6a9ea15bf2fdc69e45aaaa17e514820ac044cd559bf8e1330f17e1982616d
BLAKE2b-256 checksum
How to use checksums
1e533ff1dac5074646e2e3f04b1f1b0e4670d41e794be23fab2803d254faa97e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release files / spatial_index-1.1.0-cp27-cp27m-macosx_10_6_x86_64.whl

Download URL spatial_index-1.1.0-cp27-cp27m-macosx_10_6_x86_64.whl
Size 67.7 kB
Tags CPython 2.7 CPython 2.7 pymalloc macOS 10.6+ x86-64
SHA-256 checksum
How to use checksums
996d017e054ee844973b0f015710536a37ddfbb2de431b5168e845225c20c8ba
BLAKE2b-256 checksum
How to use checksums
5a93523fb3ac3367eefc4807cc78cb570bbc7dc6a02982bf55c6a036445dbd89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Security for spatial-index 1.1.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page