{"id":18,"date":"2014-05-28T18:34:24","date_gmt":"2014-05-28T18:34:24","guid":{"rendered":"http:\/\/www.sqlgeometry.com\/?p=18"},"modified":"2014-05-28T18:38:24","modified_gmt":"2014-05-28T18:38:24","slug":"spatial-reference-tables","status":"publish","type":"post","link":"https:\/\/www.sqlgeometry.com\/?p=18","title":{"rendered":"Spatial Reference Tables"},"content":{"rendered":"<h2>Spatial Reference Tables are the metadata of your spatial database:<\/h2>\n<p>There are two tables that are defined by the OGC standard for use with spatial column databases.<\/p>\n<ol>\n<li>geometry_columns &#8211; this table stores your catalog of data, where to find the geometry column, the dimensions of the coordinate system, the geometry type, and the SRID &#8211; Spatial Reference IDentifier (internal SRID, authority is not set here)<\/li>\n<li>spatial_ref_sys &#8211; this table contains the SRID\u00a0 used locally and associates it with an authoritative SRID (such as the <a title=\"EPSG.ORG\" href=\"http:\/\/www.epsg.org\/\">EPSG<\/a>) the spatial reference text and the proj4text.<\/li>\n<\/ol>\n<p>These tables (with a potential for a variation on name) are used in all spatial database systems that support the OGC. Even ESRI uses this method with their SDE data model.<\/p>\n<p>One can choose to use these tables or create them as views to support other views. For example I may have a table of features, and a table for locations. In my database I dont care if a feature has mixed geometries (points lines or polygons) <strong>because that is just an attribute of the thing I am interested in.\u00a0 (<\/strong>ESRI tries to make you tie everything to a point, line or polygon, and then attributes. This is backwards, and wrong).<\/p>\n<p>In any case, in my database, I can create views that organize my data into a flat file type dataset, with only one type of geometry per view. I would then want to use a view to make my spatial_reference sys tables, to catalog the views.<\/p>\n<h3>Spatial References help:<\/h3>\n<p>I have found that <a title=\"spatialreference.org\" href=\"http:\/\/spatialreference.org\/\">spatialreference.org<\/a> is really useful for working with the projects and creating these tables. There is even a link to get the SQL insert statement for the spatial reference that you are interested in.<\/p>\n<p>&nbsp;<\/p>\n<p>Here is the create code for each of the tables if this helps.<\/p>\n<pre style=\"padding-left: 30px;\">CREATE TABLE [dbo].[spatial_ref_sys](\r\n [srid] [int] NOT NULL,\r\n [auth_name] [varchar](256) NULL,\r\n [auth_srid] [int] NULL,\r\n [srtext] [varchar](2048) NULL,\r\n [proj4text] [varchar](2048) NULL,\r\n PRIMARY KEY CLUSTERED\r\n (\r\n [srid] ASC\r\n )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]\r\n ) ON [PRIMARY]<\/pre>\n<p>&nbsp;<\/p>\n<p>AND<\/p>\n<pre style=\"padding-left: 30px;\"> CREATE TABLE [dbo].[geometry_columns](\r\n [f_table_catalog] [varchar](128) NOT NULL,\r\n [f_table_schema] [varchar](128) NOT NULL,\r\n [f_table_name] [varchar](256) NOT NULL,\r\n [f_geometry_column] [varchar](256) NOT NULL,\r\n [coord_dimension] [int] NOT NULL,\r\n [srid] [int] NOT NULL,\r\n [geometry_type] [varchar](30) NOT NULL,\r\n CONSTRAINT [geometry_columns_pk] PRIMARY KEY CLUSTERED\r\n (\r\n [f_table_catalog] ASC,\r\n [f_table_schema] ASC,\r\n [f_table_name] ASC,\r\n [f_geometry_column] ASC\r\n )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]\r\n ) ON [PRIMARY]<\/pre>\n<pre style=\"padding-left: 30px;\"><\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spatial Reference Tables are the metadata of your spatial database: There are two tables that are defined by the OGC standard for use with spatial column databases. geometry_columns &#8211; this table stores your catalog of data, where to find the geometry column, the dimensions of the coordinate system, the geometry type, and the SRID &#8211; &hellip; <a href=\"https:\/\/www.sqlgeometry.com\/?p=18\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Spatial Reference Tables<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-18","post","type-post","status-publish","format-standard","hentry","category-spatial-reference"],"_links":{"self":[{"href":"https:\/\/www.sqlgeometry.com\/index.php?rest_route=\/wp\/v2\/posts\/18","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlgeometry.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqlgeometry.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlgeometry.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlgeometry.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=18"}],"version-history":[{"count":4,"href":"https:\/\/www.sqlgeometry.com\/index.php?rest_route=\/wp\/v2\/posts\/18\/revisions"}],"predecessor-version":[{"id":20,"href":"https:\/\/www.sqlgeometry.com\/index.php?rest_route=\/wp\/v2\/posts\/18\/revisions\/20"}],"wp:attachment":[{"href":"https:\/\/www.sqlgeometry.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=18"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqlgeometry.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=18"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqlgeometry.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=18"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}