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

SAP Sybase SQL Anywhere 16.0 » SQL Anywhere Server - Spatial Data Support » Spatial data


How to create geometries

There are several methods for creating geometries in a database:

  • Load from Well Known Text (WKT) or Well Known Binary (WKB) formats   You can load or insert data in WKT or WKB formats. These formats are defined by the OGC, and all spatial database vendors support them. SQL Anywhere performs automatic conversion from these formats to geometry types.

  • Load from ESRI shapefiles   You can load data from ESRI shapefiles into a new or existing table. There are a number of ways to do this.

  • Use a SELECT...FROM OPENSTRING statement   You can execute a SELECT... FROM OPENSTRING statement on a file containing the spatial data. For example:
    INSERT INTO world_cities( country, city, point )
       SELECT country, city, NEW ST_Point( longitude, latitude, 4326 )
          FROM OPENSTRING( FILE 'capitalcities.csv' ) 
                     country   CHAR(100),
                     city      CHAR(100),
                     latitude  DOUBLE,
                     longitude DOUBLE )

  • Create coordinate points by combining latitude and longitude values   You can combine latitude and longitude data to create a coordinate of spatial data type ST_Point. For example, if you had a table that already has latitude and longitude columns, you can create an ST_Point column that holds the values as a point using a statement similar to the following:
    ALTER TABLE my_table 
       ADD point AS ST_Point(SRID=4326) 
       COMPUTE( NEW ST_Point( longitude, latitude, 4326 ) );

  • Create geometries using constructors and static methods   You can create geometries using constructors and static methods.

 See also