Creating custom Coordinate System in PostGIS

It's easy here

  1. Look it up on http://www.spatialreference.org
  2. Find it SR-ORG:7069 NAD_1983_HARN_StatePlane_Michigan_South_FIPS_2113_IntlFeet
  3. Click PostGIS spatial_ref_sys INSERT statement
  4. Run that insert command.

Reproduced below,

INSERT into spatial_ref_sys (srid, auth_name, auth_srid, proj4text, srtext)
values ( 97069, 'sr-org', 7069, '', 'PROJCS["NAD_1983_HARN_StatePlane_Michigan_South_FIPS_2113_IntlFeet",GEOGCS["GCS_North_American_1983_HARN",DATUM["D_North_American_1983_HARN",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",13123359.58005249],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-84.36666666666666],PARAMETER["Standard_Parallel_1",42.1],PARAMETER["Standard_Parallel_2",43.66666666666666],PARAMETER["Latitude_Of_Origin",41.5],UNIT["Foot",0.3048]]');

Now you have SRID 7069.


TL;DR: use INSERT statements from http://epsg.io/ instead of http://www.spatialreference

I just came accross this question as I was looking for how do one inserts a new projection into the spatial_ref_sys table of Postgis. I tried the tip in the approved answer in PostgreSQL 9.5.15 with a 6 numbers-long SRID, but it failed as shown below (I replaced the real values with for brievity):

the code:

=# INSERT into spatial_ref_sys (srid, auth_name, auth_srid, proj4text, srtext)
values ( 9<the-srid> <the-auth>, <the-srid>, <the-proj4-text>, <the-sr-text>);

the error:

ERROR:  new row for relation "spatial_ref_sys" violates check constraint "spatial_ref_sys_srid_check"
DETAIL:  Failing row contains <the-row>

I looked into the schema of the spatial_ref_sys table:

=# \d spatial_ref_sys
     Table "public.spatial_ref_sys"
  Column   |          Type           | Modifiers 
-----------+-------------------------+-----------
 srid      | integer                 | not null
 auth_name | character varying(256)  | 
 auth_srid | integer                 | 
 srtext    | character varying(2048) | 
 proj4text | character varying(2048) | 
Indexes:
    "spatial_ref_sys_pkey" PRIMARY KEY, btree (srid)
Check constraints:
    "spatial_ref_sys_srid_check" CHECK (srid > 0 AND srid <= 998999)
...

It clearly shows the SRID values in this table must be 6 numbers-long at most, which is broken by the "9" that is added in front of the srid in the SQL INSERT statements provided by http://www.spatialreference. However, the same statement given by http://epsg.io/ does not have this flaw. Therefore, you are better off using this website instead of the other one.