ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

Create spatial references using SQL

  • Creating a spatial reference in IBM Db2
  • Creating a spatial reference in IBM Informix
  • Creating a spatial reference in Oracle
  • Creating a spatial reference in PostgreSQL
  • Creating a spatial reference in SQLite

Esri recommends that you create spatial references using ArcGIS Desktop tools when creating feature classes. ArcGIS provides a full suite of tools for this task and will calculate x-, y-, z-, and m-units and offsets for you to maintain high-precision data. Esri understands, though, that some users and application developers want to have options when creating spatial references. Examples of using SQL to create spatial references are provided below.

The spatial reference system is assigned to a geometry during its construction. The spatial reference system must exist in the spatial reference table. All geometries in a column must have the same spatial reference system.

Creating a spatial reference in IBM Db2

In Db2, the command to create a spatial reference is db2se create_srs (or invoke the db2se.ST_create_srs stored procedure). The following example creates a spatial reference record with a scale factor of 10 and using a specific coordinate system:

db2se create_srs mydb -srsName \"mysrs\" 
-srsID 310000 -xScale 10 -coordsysName \"GCS_North_American_1983\"

Be sure to replace the srsID (310000) with a unique value. For more information about using this command, see the IBM Knowledge Center.

Creating a spatial reference in IBM Informix

Informix users can create a spatial reference record in the spatial_references table using an INSERT statement similar to this example. Be sure to replace the SRID (310000) with a unique value.

INSERT INTO sde.spatial_references (srid, description, 
auth_name, auth_srid, falsex, falsey, xyunits, falsez, 
zunits, falsem, munits, srtext, object_flags, 
xycluster_tol, zcluster_tol, mcluster_tol)
VALUES (
 310000, 
 'GCS_North_American_1983', 
 NULL, 
 NULL, 
 -400,
 -400,
 1000000000,
 -100000,
 100000,
 -100000,
 10000, 
 'GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]',
 1,
 0,
 0,
 0
);

For more information about creating a spatial reference in Informix, see the IBM Knowledge Center.

Creating a spatial reference in Oracle

Creating a spatial reference for tables using the spatial type in Oracle is conducted via an INSERT statement like the one below. An ST_Geometry function will replace the NULL SRID value with a unique value.

INSERT INTO SDE.ST_SPATIAL_REFERENCES (SR_NAME, SRID, 
X_OFFSET, Y_OFFSET, XYUNITS, Z_OFFSET, Z_SCALE, M_OFFSET, 
M_SCALE, MIN_X, MAX_X, MIN_Y, MAX_Y, MIN_Z, MAX_Z, MIN_M, 
MAX_M, CS_ID, CS_NAME, CS_TYPE, ORGANIZATION, 
ORG_COORDSYS_ID, DEFINITION, DESCRIPTION)
VALUES (
 'GCS_North_American_1983', 
 NULL,
 -400,
 -400,
 1000000000, 
 -100000, 
 100000, 
 -100000, 
 100000, 
 9.999E35,
 -9.999E35, 
 9.999E35, 
 -9.999E35, 
 9.999E35, 
 -9.999E35, 
 9.999E35, 
 -9.999E35, 
 4269, 
 'GCS_North_American_1983',
 'PROJECTED', 
 NULL,
 NULL,
 'GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]',
 'Custom SpRef'
);

Creating a spatial reference in PostgreSQL

To create a spatial reference system for the spatial type in PostgreSQL, use an INSERT statement similar to the one below. Be sure to replace the SRID (310000) with a unique value.

INSERT INTO sde.st_spatial_references (sr_name, srid, 
x_offset, y_offset, xyunits, z_offset, z_scale, m_offset, 
m_scale, min_x, max_x, min_y, max_y, min_z, max_z, min_m, 
max_m, cs_id, cs_name, cs_type, organization, 
org_coordsys_id, definition, description)
VALUES (
 'GCS_North_American_1983',
 310000, 
 -400, 
 -400, 
 1000000000,
 -100000, 
 100000, 
 -100000, 
 100000, 
 9.999E35,
 -9.999E35, 
 9.999E35, 
 -9.999E35, 
 9.999E35, 
 -9.999E35, 
 9.999E35, 
 -9.999E35, 
 4269, 
 'GCS_North_American_1983',
 'PROJECTED', 
 NULL,
 NULL,
 'GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]',
 'Custom SpRef'
);

Creating a spatial reference in SQLite

Use an INSERT statement similar to the following example to add a spatial reference to the st_aux_spatial_reference_systems table in a SQLite database that uses ST_Geometry. Be sure to replace the SRID (310000) with a unique value.

INSERT INTO st_aux_spatial_reference_systems (srid, auth_name, auth_srid, 
sr_text, falsex, falsey, xyunits, falsez, zunits, falsem, 
munits, xycluster_tol, zcluster_tol, mcluster_tol)
VALUES (
 310000, 
 NULL, 
 4269, 
 'GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]',
 -400, 
 -400, 
 1000000000,
 -100000, 
 1.0, 
 -100000, 
 1.0, 
 0,
 0,
 0 
);

Related topics

  • Spatial references

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2021 Esri. | Privacy | Legal