4

If I have a specific SRID set on a geometry column in PostGIS, say 4326; if I then insert geometry with a different SRID, say 4283, what SRID will be stored in the database, will PostGIS transform the geometry to the column SRID on entry or will it just not allow insertion?

INSERT INTO sometable(geom) VALUES ST_GeomFromText('POINT(-38.2481 141.7370)',4283)

geometry_columns view

1
  • 2
    It should not be possible to do that. For me insert into test(wkb_geometry) values (ST_GeomFromText('POINT(-38.2481 141.7370)',4283)) gives ERROR: Geometry SRID (4283) does not match column SRID (4326) SQL state: 22023
    – user30184
    Sep 8, 2020 at 7:44

1 Answer 1

5

If your column is seen as registered in the PostGIS geometry|geography_columns system View (meaning that its constraints are known in the system relations), the typemod constraints of the data type (GEOMETRY|GEOGRAPHY) are going to get enforced; if it is set to a specific SRID typemod, you cannot INSERT data that violates that inherent constraint, or UPDATE an existing row in that manner.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.