Preparing for spatial data

Before you load spatial data, you must prepare the database server for spatial data.

Before you begin

The database that contains the spatial data must meet the following requirements or the message DataBlade registration failed is printed in the online log:

  • The database must be logged.
  • The database must not be defined as an ANSI database.

The Scheduler must be running in the database server. If the Scheduler is not running when you create a spatial data type or run a spatial routine, a message that the data type is not found or the routine cannot be resolved is returned.

Procedure

To prepare for spatial data:
  1. Set the STACKSIZE configuration parameter in the onconfig file to at least 64.
    Increasing the stack size prevents stack overflow errors.
  2. Create the system sbspace by setting the SYSSBSPACENAME configuration parameter in the onconfig file.
    When the UPDATE STATISTICS MEDIUM or HIGH statements are run on spatial tables, the database server stores the statistics in the system sbspace, which is specified by the SYSSBSPACENAME configuration parameter in the onconfig file. If you do not set the SYSSBSPACENAME configuration parameter, the database server creates the system sbspace when you create a spatial table or run a spatial routine. The system sbspace is created from the storage pool, if the storage pool is set up. Otherwise, the system sbspace is created in the same directory as the root dbspace.
  3. Create an sbspace for spatial metadata and move the metadata into it.
    If you do not move the spatial metadata, spatial metadata is stored in the default sbspace, which is specified by the SBSPACENAME configuration parameter. If you do not set the SBSPACENAME configuration parameter in the onconfig file, the database server creates the default sbspace when you create a spatial table or run a spatial routine. The default sbspace is created from the storage pool, if the storage pool is set up. Otherwise, the default sbspace is created in the same directory as the root dbspace.
    1. Create an sbspace by running the onspaces -c -S command.
    2. Move the spatial metadata into the sbspace by running the following command:
      ALTER TABLE SE_MetadataTable PUT smd IN (mysbspace);
    3. Initialize the spatial metadata infrastructure by running the following command:
      EXECUTE FUNCTION SE_MetadataInit();
  4. Create an sbspace to store spatial data by running the onspaces -c -S command. Include the -DF "LOGGING=ON" option to create the spatial data sbspace with logging, so that you can back up and restore both the user data and the metadata.
    If you do not create an sbspace for spatial data and reference the sbspace in the PUT clause in the CREATE TABLE statement, spatial data is stored in the default sbspace. Spatial data is stored in the sbspace when a geometry exceeds 930 bytes, for example, a line or polygon with more than 50 vertices.
  5. Choose a predefined spatial reference system in the spatial_references table or create your own spatial reference system and add it to the spatial_references table. To add a spatial reference system into the spatial_references table:
    • Insert a row into the spatial_references table with an INSERT statement.
    • Run the SE_CreateSRID() function.
    • Run the SE_CreateSRID() function. Specify the limits of the X and Y extents or specify an existing system on which to base the new system. The database server calculates the false origin and system units.
  6. Optional: Choose or create the unit of measure for the coordinate system.
    If you want to calculate the distance or area for geometries that have angular units, choose a predefined unit of measure in the st_units_of_measure table or create your own unit of measure and add it to the st_units_of_measure table with an INSERT statement.
  7. Create a table for the spatial data by running the CREATE TABLE statement with a spatial column in the column clause. If you created an sbspace for spatial data, include the PUT clause in the CREATE TABLE statement.
    You can create the table as part of loading data if you use the loadshp utility to load ESRI shapefiles.