Skip to main content

Library for generating DBMS spatial index constraints.

Project description

# 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.

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.

spatial_index-1.1.0-cp38-cp38-manylinux2010_x86_64.whl (213.1 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.12+ x86-64

spatial_index-1.1.0-cp38-cp38-manylinux1_x86_64.whl (213.1 kB view details)

Uploaded CPython 3.8

spatial_index-1.1.0-cp38-cp38-macosx_10_9_x86_64.whl (69.8 kB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

spatial_index-1.1.0-cp37-cp37m-manylinux2010_x86_64.whl (187.7 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.12+ x86-64

spatial_index-1.1.0-cp37-cp37m-manylinux1_x86_64.whl (187.7 kB view details)

Uploaded CPython 3.7m

spatial_index-1.1.0-cp37-cp37m-macosx_10_7_x86_64.whl (69.5 kB view details)

Uploaded CPython 3.7mmacOS 10.7+ x86-64

spatial_index-1.1.0-cp36-cp36m-manylinux2010_x86_64.whl (185.7 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.12+ x86-64

spatial_index-1.1.0-cp36-cp36m-manylinux1_x86_64.whl (185.7 kB view details)

Uploaded CPython 3.6m

spatial_index-1.1.0-cp36-cp36m-macosx_10_6_intel.whl (95.1 kB view details)

Uploaded CPython 3.6mmacOS 10.6+ Intel (x86-64, i386)

spatial_index-1.1.0-cp27-cp27m-manylinux2010_x86_64.whl (177.9 kB view details)

Uploaded CPython 2.7mmanylinux: glibc 2.12+ x86-64

spatial_index-1.1.0-cp27-cp27m-manylinux1_x86_64.whl (177.9 kB view details)

Uploaded CPython 2.7m

spatial_index-1.1.0-cp27-cp27m-macosx_10_6_x86_64.whl (67.7 kB view details)

Uploaded CPython 2.7mmacOS 10.6+ x86-64

File details

Details for the file spatial_index-1.1.0-cp38-cp38-manylinux2010_x86_64.whl.

File metadata

  • Download URL: spatial_index-1.1.0-cp38-cp38-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 213.1 kB
  • Tags: CPython 3.8, manylinux: glibc 2.12+ x86-64
  • Uploaded using 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

File hashes

Hashes for spatial_index-1.1.0-cp38-cp38-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 9aa327b7fb4e5d956ca20a258bb8b951a5df7f0959e0a6afd786bc48214d715f
MD5 abe332846020694c7a66b1ee617bfcc7
BLAKE2b-256 a6941612a1da27f9bf826d14392c3815709e579f76b42cf6b4c8a1f56d36f2ee

See more details on using hashes here.

File details

Details for the file spatial_index-1.1.0-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: spatial_index-1.1.0-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 213.1 kB
  • Tags: CPython 3.8
  • Uploaded using 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

File hashes

Hashes for spatial_index-1.1.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ea3e76cb689424c126e5b4dbb801b94405e5fd7617461f499cebbb68be81d800
MD5 3cc5a79d143fdf8e87b24c6d7500ed6a
BLAKE2b-256 579bd6ab60ee0459def8225a82cc8d54f30a7684a4931e552f09678e72663107

See more details on using hashes here.

File details

Details for the file spatial_index-1.1.0-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: spatial_index-1.1.0-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 69.8 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using 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

File hashes

Hashes for spatial_index-1.1.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ad28b2de7f0a0b06a06b8dc24e8408b5f0e977c396a28290bf2455cc87179368
MD5 b04db2c1fc81876bad248dbb105317a4
BLAKE2b-256 901f7e5bc70ae9b767575a34c9b875feb224c9baf7fa6045dc8dfce474290530

See more details on using hashes here.

File details

Details for the file spatial_index-1.1.0-cp37-cp37m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: spatial_index-1.1.0-cp37-cp37m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 187.7 kB
  • Tags: CPython 3.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using 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

File hashes

Hashes for spatial_index-1.1.0-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 f1c118782e0e16aa366ac5cf9bb5753590a7e36e26a4f0c05521e412a293d8a0
MD5 25c09166cefb63e55b2250af7417d771
BLAKE2b-256 dfea618b0e1c4d1f15c68757adf9c5cf9a4a8b58aee1b017027ea159b12b8c33

See more details on using hashes here.

File details

Details for the file spatial_index-1.1.0-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: spatial_index-1.1.0-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 187.7 kB
  • Tags: CPython 3.7m
  • Uploaded using 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

File hashes

Hashes for spatial_index-1.1.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c5e29f476f8939ea053daacd381636ebaf8aae75e30521f256645dc840da5b8d
MD5 9526173b983842f82e5881a614595e8d
BLAKE2b-256 288f2867370c9cbcb92af6b213501b797d0077cf5c5d11930530630bdb2c821e

See more details on using hashes here.

File details

Details for the file spatial_index-1.1.0-cp37-cp37m-macosx_10_7_x86_64.whl.

File metadata

  • Download URL: spatial_index-1.1.0-cp37-cp37m-macosx_10_7_x86_64.whl
  • Upload date:
  • Size: 69.5 kB
  • Tags: CPython 3.7m, macOS 10.7+ x86-64
  • Uploaded using 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

File hashes

Hashes for spatial_index-1.1.0-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 c6832690fb413fa0e92c127ae191f77ecbabee99420d3947a4d637fe760446e9
MD5 10c83778c113d70bf859bec5d9b8eeb2
BLAKE2b-256 8876a0a33938b8ea74ac55e263a1019ba1cdd833b1873f6b1d021b5b383093c6

See more details on using hashes here.

File details

Details for the file spatial_index-1.1.0-cp36-cp36m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: spatial_index-1.1.0-cp36-cp36m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 185.7 kB
  • Tags: CPython 3.6m, manylinux: glibc 2.12+ x86-64
  • Uploaded using 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

File hashes

Hashes for spatial_index-1.1.0-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 52f630f830a7f084155ff5a57798d653f06b8d9f56d3e056e126e10555b2e48d
MD5 72c5232166c76ca079462024eb726b31
BLAKE2b-256 bf5d7b2b65de018edfeef6ea3d39538b2055128cf1daab8678d549c39b61b6be

See more details on using hashes here.

File details

Details for the file spatial_index-1.1.0-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: spatial_index-1.1.0-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 185.7 kB
  • Tags: CPython 3.6m
  • Uploaded using 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

File hashes

Hashes for spatial_index-1.1.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2a8d24660748232378d8ad22144fcbe8a7d95cc697639554b166189b2341708a
MD5 0c4cdf47e20318b2b225e64812de38cb
BLAKE2b-256 cf12131a3e81c376b1faecdccee154217fe3faef9cd6d8f0b6ad6bd0e577416f

See more details on using hashes here.

File details

Details for the file spatial_index-1.1.0-cp36-cp36m-macosx_10_6_intel.whl.

File metadata

  • Download URL: spatial_index-1.1.0-cp36-cp36m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 95.1 kB
  • Tags: CPython 3.6m, macOS 10.6+ Intel (x86-64, i386)
  • Uploaded using 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

File hashes

Hashes for spatial_index-1.1.0-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 b042c1dd9240740e4dfc07d6a96799d200656400f9ccad202d5824e9845fe000
MD5 5899af4af3be3972aa581e3a40cfef9d
BLAKE2b-256 51318d34d813273ddde62c46946a8fb7630ca29e285ee199bd6990b55643321f

See more details on using hashes here.

File details

Details for the file spatial_index-1.1.0-cp27-cp27m-manylinux2010_x86_64.whl.

File metadata

  • Download URL: spatial_index-1.1.0-cp27-cp27m-manylinux2010_x86_64.whl
  • Upload date:
  • Size: 177.9 kB
  • Tags: CPython 2.7m, manylinux: glibc 2.12+ x86-64
  • Uploaded using 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

File hashes

Hashes for spatial_index-1.1.0-cp27-cp27m-manylinux2010_x86_64.whl
Algorithm Hash digest
SHA256 10e88066979dc127c408f26a0f7c50c7403d03fad188adb9284529ce0ade6ed3
MD5 cfff57bd381b5d2bdebabcc331635ddc
BLAKE2b-256 c48f4eb05b8deecf19962f536eab983a23b11ddd346875b163b76b0e63e6fcbc

See more details on using hashes here.

File details

Details for the file spatial_index-1.1.0-cp27-cp27m-manylinux1_x86_64.whl.

File metadata

  • Download URL: spatial_index-1.1.0-cp27-cp27m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 177.9 kB
  • Tags: CPython 2.7m
  • Uploaded using 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

File hashes

Hashes for spatial_index-1.1.0-cp27-cp27m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4ca6a9ea15bf2fdc69e45aaaa17e514820ac044cd559bf8e1330f17e1982616d
MD5 4bdc84a250e8136cb536dd08794253ea
BLAKE2b-256 1e533ff1dac5074646e2e3f04b1f1b0e4670d41e794be23fab2803d254faa97e

See more details on using hashes here.

File details

Details for the file spatial_index-1.1.0-cp27-cp27m-macosx_10_6_x86_64.whl.

File metadata

  • Download URL: spatial_index-1.1.0-cp27-cp27m-macosx_10_6_x86_64.whl
  • Upload date:
  • Size: 67.7 kB
  • Tags: CPython 2.7m, macOS 10.6+ x86-64
  • Uploaded using 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

File hashes

Hashes for spatial_index-1.1.0-cp27-cp27m-macosx_10_6_x86_64.whl
Algorithm Hash digest
SHA256 996d017e054ee844973b0f015710536a37ddfbb2de431b5168e845225c20c8ba
MD5 24cb737d058682c7d9c1ab04c2451bf9
BLAKE2b-256 5a93523fb3ac3367eefc4807cc78cb570bbc7dc6a02982bf55c6a036445dbd89

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