2

I'm trying to create a table into my PostGIS 2.3

CREATE TABLE destinations (
    id          serial                      PRIMARY KEY,
    sector      integer                     REFERENCES sectors(id),
    name        varchar(64)                 NOT NULL,
    location    geography(POINT, 25831)     NOT NULL,
    authcode    varchar(16)                 NOT NULL
);

I specify the SRS ESPG:25831 that I'm using to the location field, but I get this error:

ERROR:  Only lon/lat coordinate systems are supported in geography.
LINE 6: location    geography(POINT,25831)      NOT NULL,

I've checked the spatial_ref_sys table and 25831 is there. I also have enabled the PostGIS extension. In fact, my query works if I remove the SRS:

location    geography(POINT)     NOT NULL,

Any idea of what am I doing wrong?

Jordi Nebot
  • 288
  • 4
  • 21

1 Answers1

4

If you use a projection, you have to use the geometry type instead. The geography type is only valid for coordinates in WGS 84 GCS.

More information can be found here:

Difference between geometry and geography type

Pros and Cons of geometry and geography type

Try

location    geometry(POINT, 25831) 
Greg Z
  • 827
  • 5
  • 12