Example: Add a Spatial Index to a Table

A typical use of an index is to provide a spatial index on a geom field in a table, so the geom data can be visualized in a drawing.  Although most tables from data sources that create drawing will have such an index automatically added, at times depending on how the data was imported or created we might need to add a spatial index manually.  This example shows how to add a spatial index using a geom field in a table.

 

The data set we use consists of a table called Roads Table that contains geom data for lines stored in a Geom field.   It is a data set of roads.

eg_add_spatialx01_01.png

 

We open the Roads Table table and with the focus on the Roads Table window we choose Edit-Schema.  The dialog opens with a display of the schema of the Roads Table table.

 

eg_add_spatialx01_02.png

 

We click on <new index> to create a new index.

 

eg_add_spatialx01_03.png

 

In the controls that open up we first name the new index.   We will name it Geom_x using the recommended Manifold style of naming indexes after the field they index with a _x appended.    We also choose from the list an rtree type of index.

 

eg_add_spatialx01_04.png

 

Having made those choices we press Add.   We now specify which field will be used for the index.

 

eg_add_spatialx01_05.png

 

The Field box is loaded with the names of fields we can use.  We choose the Geom field.

 

eg_add_spatialx01_06.png

 

We press Add.   tech_angus_sm.png

 

Tech Tip:  The number one mistake made when creating an index is to forget to press Add in this step and instead just pressing OK.   Until we add the Geom field to the Geom_x index we have just created, the index cannot do anything, because we have not told it which field it should index.  

 

 

eg_add_spatialx01_07.png

 

After double-checking our work we press OK to close the Schema dialog.

 

Now that we have a spatial index on the Geom field we can now open up the Roads drawing that displays data taken from the Geom field.

eg_add_spatialx01_08.png

This particular data set shows the path of Roman roads created during the Roman empire.

 

See Also

Tables

 

Adding an Index to a Table

 

Example: Add a UUID-based Index to a Table - Create a new computed field that is filled with UUID values on creation and then create an index on that field.   This technique creates an indexed field that has guaranteed unique values for all records and thus the indexed field and record values may be used in other projects.