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.



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.




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




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.




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




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




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.  





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.


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


See Also



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.