spatial_index Docstrings¶
-
class
spatial_index.
SpatialIndex
¶ SpatialIndex class
This spatial indexing class provides functions for converting astronomical spatial constraints (cone or convex polygon on the sky) into constraints appropriate for inclusion in SQL DBMS searches. It is assumed that the DBMS tables have been augmented with a spatial index (integer) column at some HTM or HEALPix level and (x,y,z) three-vector coordinates for each record.
-
cone_search
¶ cone_search() converts a cone on the sky (RA, Dec, radius) into a pair of SQL fragments that can be added to an SQL statement.
- Parameters
ra (double, required) – Right Ascension (decimal degrees J2000) of center of search cone.
dec (double, required) – Declination (decimal degrees J2000) of center of search cone.
radius (double, required) – Radius (decimal degrees) of search cone.
mode (integer, optional, default 0 (SpatialIndex.HTM)) – Indexing mode (SpatialIndex.HTM or SpatialIndex.HPX)
level (double, optional, default 7) – Depth of the indexing.
xcol (string, optional, default 'x') – Column name for sky position three-vector X component
ycol (string, optional, default 'y') – Column name for sky position three-vector Y component
zcol (string, optional, default 'z') – Column name for sky position three-vector Z component
colname (string, optional, default depends on mode and encoding) – Column name for sky position three-vector Z component
encoding (string, optional, default depends on mode and encoding) – Column name for sky position three-vector Z component
- Returns
The return is a dictionary with integer status and two strings
index_constraint (specifying the spatial index cells covered) and
geom_constraint (an exact filter for the sky region). If the return
status is 1, an error_message is returned instead.
-
polygon_search
¶ polygon_search() converts a convex polygon on the sky into a pair of SQL fragments that can be added to an SQL statement.
- Parameters
npoly (int, required) – Number of polygon points (greater than or equal to 3)
ra (double list, required) – Right Ascensions (decimal degrees J2000) of the polygon points.
dec (double, required) – Declinations (decimal degrees J2000) of the polygon points.
mode (integer, optional, default 0 (SpatialIndex.HTM)) – Indexing mode (SpatialIndex.HTM or SpatialIndex.HPX)
level (double, optional, default 7) – Depth of the indexing.
xcol (string, optional, default 'x') – Column name for sky position three-vector X component
ycol (string, optional, default 'y') – Column name for sky position three-vector Y component
zcol (string, optional, default 'z') – Column name for sky position three-vector Z component
colname (string, optional, default depends on mode and encoding) – Column name for sky position three-vector Z component
encoding (string, optional, default depends on mode and encoding) – Column name for sky position three-vector Z component
- Returns
The return is a dictionary with integer status and two strings
index_constraint (specifying the spatial index cells covered) and
geom_constraint (an exact filter for the sky region). If the return
status is 1, an error_message is returned instead.
-