Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 12.0.0 » SQL Anywhere Server - Spatial Data Support » Getting started with spatial data » Spatial data usage topics


View spatial data as images

When working with spatial data, you may want to view a geometry as an image to understand what the data represents. SQL Anywhere offers two ways of viewing geometries:

  • Spatial Preview tab   The Spatial Preview tab is available from the Results pane in Interactive SQL. It allows you to look at geometry values one at a time in the results.

  • Spatial Viewer   The Spatial Viewer is available from the Tools menu in Interactive SQL. It combines all geometries reflected in the results of a query into one image.

    Each instance of Interactive SQL is associated with a different connection to a database. When you open an instance of the Spatial Viewer from within Interactive SQL, that instance of Spatial Viewer remains associated with that instance of Interactive SQL, and shares the connection to the database.

    This means that when you execute a query in the Spatial Viewer, if you attempt to execute a query in the associated instance of Interactive SQL, you will get an error. Likewise, if you have multiple instances of the Spatial Viewer open that were created by the same instance of Interactive SQL, only one of those instances can execute a query at a time; the rest have to wait for the query to finish.

 To view a geometry in Interactive SQL
  1. Execute the following query in Interactive SQL:

    SELECT * FROM SpatialShapes;
  2. Double-click the any value in the Shapes column in the Results pane to open the value in the Value window.

    The value is displayed as text on the Text tab of the Value window.


    By default, Interactive SQL truncates values in the Results pane to 256 characters. If Interactive SQL returns an error indicating that the full column value could not be read, increase the truncation value. To do this, choose Tools » Options and pick SQL Anywhere in the left pane. On the Results tab, change Truncation Length to a high value such as 5000. Click OK to save your changes, and execute the query again.

  3. Click the Spatial Preview tab to see the geometry as a Scalable Vector Graphic (SVG).

    Accessibility description
  4. Use the Previous Row and Next Row buttons to view other rows in the result set.

 To view a geometry using the Spatial Viewer
  1. In Interactive SQL, select Tools » Spatial Viewer.

  2. In the Spatial Viewer, execute the following query in the SQL pane and then click Execute:

    SELECT * FROM SpatialShapes;
    Set of colored polygons and lines displayed in the Spatial Viewer

    The image displayed in the Results area reflects all of the geometries in the result set. This is different from viewing geometries in the Spatial Preview tab in Interactive SQL, where you only see a preview of the geometry you selected from the results.

    The order of rows in a result matter to how the image appears in the Spatial Viewer because the image is drawn in the order in which the rows are processed, with the most recent appearing on the top. This means that shapes that occur later in a result set can obscure ones that occur earlier in the result set.

    You can use the Draw Outlined Polygons tool to remove the coloring from the polygons in a drawing to reveal the outline of all shapes. This tool is located beneath the image, near the controls for saving, zooming, and panning. Here is an example of how the image appears as outlines:

    Set of polygon outlines and lines displayed in the Spatial Viewer